GetSocketTransform results in error

I have the following code:

			FVector Start = Hero->GetWeaponComponent()->GetSocketLocation(FName("SOCKET_MuzzleFlash"));
			FVector End = Hero->GetCameraBoom()->GetComponentLocation() + Hero->GetFollowCamera()->GetForwardVector() * Range;
			FRotator Rotation = UKismetMathLibrary::FindLookAtRotation(Start, End);

			FGameplayEffectSpecHandle DamageEffectSpecHandle = MakeOutgoingGameplayEffectSpec(DamageGameplayEffect, GetAbilityLevel());

			// Pass the damage to the Damage Execution Calculation through a SetByCaller value on the GameplayEffectSpec
			DamageEffectSpecHandle.Data.Get()->SetSetByCallerMagnitude(FGameplayTag::RequestGameplayTag(FName("Data.Damage")), Damage);

			FTransform MuzzleTransform = Hero->GetWeaponComponent()->GetSocketTransform(FName("SOCKET_MuzzleFlash"));
			MuzzleTransform.SetRotation(Rotation.Quaternion());
			MuzzleTransform.SetScale3D(FVector(1.0f));

The following line breaks my code:

FTransform MuzzleTransform = Hero->GetWeaponComponent()->GetSocketTransform(FName("SOCKET_MuzzleFlash"));

Here is my stacktrace:

| |UnrealEditor-GameplayAbilities.dll!00007ff92eddc32a()|Unknown|
|---|---|---|
| |UnrealEditor-GameplayAbilities.dll!00007ff92ee2e0f2()|Unknown|
|>|UnrealEditor-Escape_from_Caelum-0025.dll!UEFCGA_FireGun::EventReceived(FGameplayTag EventTag, FGameplayEventData EventData) Line 93|C++|
| |UnrealEditor-Escape_from_Caelum-0025.dll!UEFCGA_FireGun::execEventReceived(UObject * Context, FFrame & Stack, void * const Z_Param__Result) Line 29|C++|

Can anyone tell me whats going on?

Have you considered doing a nullptr check before Hero->GetWeaponComponent()?
What if the weapon isn’t assigned and you are just accessing a null pointer?