theoretical bug (crash) if realloc fails - but if it fails, we will leak,

so... it only moves to be another bug.



SVN revision: 46767
This commit is contained in:
Carsten Haitzler 2010-03-02 02:30:03 +00:00
parent c7d15e868a
commit d99307b828
1 changed files with 10 additions and 1 deletions

View File

@ -556,8 +556,17 @@ img_free(Img *img)
strshr_freeme_count += 3;
if (strshr_freeme_count > strshr_freeme_alloc)
{
const char **tmp;
strshr_freeme_alloc += 32;
strshr_freeme = realloc(strshr_freeme, strshr_freeme_alloc * sizeof(const char **));
tmp = realloc(strshr_freeme, strshr_freeme_alloc * sizeof(const char **));
if (tmp) strshr_freeme = tmp;
else
{
strshr_freeme_alloc -= 32;
strshr_freeme_count -= 3;
return;
}
}
strshr_freeme[strshr_freeme_count - 3] = img->key;
strshr_freeme[strshr_freeme_count - 2] = img->file.file;