diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-07-05 11:57:17 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2014-07-05 11:57:17 -0700 |
commit | 44a450461b6361d691c360438af21fa3be21c408 (patch) | |
tree | 146dec131aa4ca764afd1ad18410266d843b1904 /fslsfonts.c | |
parent | 79344cb17e9b6b3d16ae2067b7d6e16ae204e52f (diff) |
Abort on malloc/realloc failure
cppcheck still warns about our use of realloc, but it's harmless:
[fslsfonts.c:268]: (error) Common realloc mistake: 'font_list' nulled
but not freed upon failure
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'fslsfonts.c')
-rw-r--r-- | fslsfonts.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fslsfonts.c b/fslsfonts.c index d902001..48d077d 100644 --- a/fslsfonts.c +++ b/fslsfonts.c @@ -270,6 +270,11 @@ get_list(const char *pattern) else font_list = (FontList *) malloc((unsigned) (font_cnt + available) * sizeof(FontList)); + if (font_list == NULL) { + fprintf(stderr, "%s: unable to allocate %zu bytes for font list\n", + program_name, (font_cnt + available) * sizeof(FontList)); + exit(-1); + } for (i = 0; i < available; i++) { font_list[font_cnt].name = fonts[i]; |