On Thu Nov 16 06:55:21 2023 +0000, Matteo Bruni wrote:
Sorry, I missed this MR somehow. It seems to me that this patch does it backwards, in a way. Specifically, the HeapAlloc(sizeof(string)) are replaced with malloc(), while the heap_alloc(strlen(string)) + CopyMemory() become strdup(). The former is okay, although we could replace the whole memory allocation + string copy with strdup() just fine. The latter changes behavior slightly, in that it was previously copying the string without the string terminator while now it allocates and copies that extra byte. Now, to be fair, this effectively "depended" on the arbitrary value that happens to be on that (last + 1) byte, but then again it should probably be improved anyway to allocate the extra byte and explicitly set it to some value != 0.
Thanks for the feedback! I've amended the patch to use strdup in asm.c and explicitly remove the null terminators in hlsl_d3d9.c.