On Tue Nov 28 20:30:48 2023 +0000, Alex Henrie wrote:
To be clear, do you mean that you prefer Matteo's version, or the one I originally proposed? GCC apparently thinks that colour_count might be 0, which means that realloc might free palette and return NULL. It's not smart enough to warn about the hypothetically dangling pointer that was saved to image->palette in Matteo's version because the pointer is not dereferenced in the immediate context, and even if it were dereferenced immediately, GCC still only warns when compiling with -fanalyzer.
Yes, I prefer Matteo's diff.