ini
ini copied to clipboard
free(ini->data) crashes on non-standard libc
Some non-standard libc's (such as on game SDKs or other embedded systems) do not do null checks before freeing memory. I think at least the free(ini->data)
line in ini.c should have a check added there so there would not be a crash if a file is not found. Could this be done?
Thanks
As ini_load on success always allocates atleast '\0'1 ini->data could never be NULL. However, what is missing is the check..
ini->data = malloc(sz + 1);
if (!ini->data) {
goto fail;
}
.. which would make sense to check for consistency as the malloc above2 it is checked as well..
ini = malloc(sizeof(*ini));
if (!ini) {
goto fail;
}
1 https://github.com/rxi/ini/blob/master/src/ini.c#L200 2 https://github.com/rxi/ini/blob/master/src/ini.c#L182