Compare commits

...

2 Commits

Author SHA1 Message Date
N-R-K ade829a448
Merge 3bf639bb3c into 5736b15f7e 2023-02-05 13:01:58 +01:00
NRK 3bf639bb3c stb_include: close file if malloc fails 2022-03-12 16:49:10 +06:00
1 changed files with 4 additions and 1 deletions

View File

@ -66,7 +66,10 @@ static char *stb_include_load_file(char *filename, size_t *plen)
len = (size_t) ftell(f);
if (plen) *plen = len;
text = (char *) malloc(len+1);
if (text == 0) return 0;
if (text == 0) {
fclose(f);
return 0;
}
fseek(f, 0, SEEK_SET);
fread(text, 1, len, f);
fclose(f);