A latent bug in UTextureFactory

In Engine/Source/Editor/UnrealEd/Private/Factories/EditorFactories.cpp from 3571 to 3586.

			if ( PngImageWrapper->GetRaw( Format, BitDepth, RawPNG ) )
			{
				uint8* MipData = Texture->Source.LockMip(0);
				FMemory::Memcpy( MipData, RawPNG->GetData(), RawPNG->Num() );

				// Replace the pixels with 0.0 alpha with a color value from the nearest neighboring color which has a non-zero alpha
				FillZeroAlphaPNGData( Texture->Source, MipData );
			}
			else
			{
				Warn->Logf(ELogVerbosity::Error, TEXT("Failed to decode PNG.") );
				Texture->Source.UnlockMip(0);
				Texture->MarkPendingKill();
				return nullptr;
			}
			Texture->Source.UnlockMip(0);

Texture->Source.LockMip(0); and Texture->Source.UnlockMip(0); were not paired in individual blocks.

Of cource, probability of executing failure code that is else block is very very low so it will not be a problem in most cases however should consider one in ten thousand case.

			if ( PngImageWrapper->GetRaw( Format, BitDepth, RawPNG ) )
			{
				uint8* MipData = Texture->Source.LockMip(0);
				FMemory::Memcpy( MipData, RawPNG->GetData(), RawPNG->Num() );

				// Replace the pixels with 0.0 alpha with a color value from the nearest neighboring color which has a non-zero alpha
				FillZeroAlphaPNGData( Texture->Source, MipData );
				Texture->Source.UnlockMip(0);
			}
			else
			{
				Warn->Logf(ELogVerbosity::Error, TEXT("Failed to decode PNG.") );
				Texture->MarkPendingKill();
				return nullptr;
			}

Above is much more correct I think. Additionally, the Texture was not locked before these blocks. so the Unlock in else block is needless.

Hey donggas90-

I would suggest creating a pull request on GitHub with your suggested changes. Doing so is the best way to offer a contribution to improve the engine.

Cheers