Transient texture has random colors

Hi. I’m using Transient textures in order to convert some data from a file to a texture to be able to use it from a material, but when I set the data it seems to have undesired colors and I can’t figure out why. On my current example I’m setting everything to 0, so I’d expect the texture to be completely black.

My .h:

#pragma once

#include "Runtime/Engine/Classes/Engine/Texture2D.h"

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Test.generated.h"

UCLASS()
class DYNAMICTEXTURETEST_API ATest : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	ATest();
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Procedural Texture")
	UTexture2D *Texture;

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
};

My cpp:

#include "Test.h"

ATest::ATest()
{
	PrimaryActorTick.bCanEverTick = false;
}

void ATest::BeginPlay()
{
	Super::BeginPlay();
int32 width = 16;
int32 height = 16;
int32 channels = 4;
Texture = UTexture2D::CreateTransient(width, height, EPixelFormat::PF_B8G8R8A8);
FUpdateTextureRegion2D *Region = new FUpdateTextureRegion2D(0, 0, 0, 0, width, height);
Texture->AddToRoot();
Texture->SRGB = false;
Texture->AddressX = TextureAddress::TA_Clamp;
Texture->AddressY = TextureAddress::TA_Clamp;
Texture->Filter = TextureFilter::TF_Bilinear;
Texture->UpdateResource();
uint8* data = new uint8[width * height * channels];
for (int i = 0; i < width * height * channels; i++)
{
	data[i] = 0;
}
TFunction<void(uint8* SrcData, const FUpdateTextureRegion2D* Regions)> DataCleanupFunc =
	[](uint8* SrcData, const FUpdateTextureRegion2D* Regions) {
	delete[] SrcData;
};
Texture->UpdateTextureRegions(0, 1, Region, width * height * channels, channels, data, DataCleanupFunc);
}

What I see:

292370-badtexture.png

The result varies on each try. It seems to display the correct colors when the height is 1, but I need to display the full picture.