[Scripting] DOpusFactory.Blob initializes to RAM content?

If I write an "empty" blob initialized to 1 MB to a file like this:

var one_million_bytes = 1000000;
var oneMegabyteBlob = DOpusFactory.Blob(one_million_bytes)
var f = DOpus.FSUtil.OpenFile("C:\dopuswrt.tmp", "wa");
f.Write(oneMegabyteBlob);
f.Close();

...if I open that dopuswrt.tmp file in a text editor (such as Sublime Text) it will display random garbage, I even saw a PNG header in there :smiley:

I think the blob should initialize to some kind of zero values or something, but it seems its content is some random content of RAM?

Is this method not?

blob.resize
blob.Init

Resizes the Blob to the specified number of bytes.

Initialises the contents of the Blob (every byte within the blob will be set to 0). Equivalent to Set(0).

1 Like

You're right, blob.Init clears it (and blob.Resize is not needed if creating the blob with size parameter directly).

So without blob.Init we get random RAM content each time with the size being exactly specified amount of bytes (as it should be).

The issue I think is whether or not the blob.Init should be implied when creating the blob directly with DOpusFactory.Blob(one_million_bytes).

Current behavior allows for accidentally saving the unencrypted RAM content which potentially contains private data such as banking information, passwords, evidence of pirating Opus porn etc.