The following patch fixes:
- A possible double free and freed memory dereference as well as some other side effects in Util.cpp (if the allocation of pwText failed, it tried to free it and continue instead of returning).
- A silly warning caused by extra parentheses in gbGfx.cpp
- An undefined behavior in elf.cpp. I had to guess what the intention was. As it was this statement "(data++);" I assumed that being the dereferenced value unused, it wasn't the pointer but the object pointed to the one to increase.
- Incorrect use of memset (sizeof(u8) instead of the amount of u8 elements in the array of data) in SDL.cpp.
V668 There is no sense in testing the 'pwText' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. util.cpp 456
V668 There is no sense in testing the 'pwText' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. util.cpp 503
Well, the check was there in the original, but it tried to free pwText instead (which is by itself weird, as it tried to free ONLY if null).
I have nothing against modifying the patch to avoid even checking for null, if you want.