From 6ffcd815f9e178ee90ca5c6347498981a6350c36 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 30 Jun 2012 12:59:50 -0300 Subject: [PATCH] tools/libtxt/font.c (free_image, free_font): allow NULL pointer --- tools/libtxt/font.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/libtxt/font.c b/tools/libtxt/font.c index 8406f88..915eb04 100644 --- a/tools/libtxt/font.c +++ b/tools/libtxt/font.c @@ -152,8 +152,10 @@ struct image *load_image(const char *name, const char **error) void free_image(struct image *img) { - free(img->data); - free(img); + if (img) { + free(img->data); + free(img); + } } @@ -238,8 +240,10 @@ struct font *make_font(struct image *img, const char **error) void free_font(struct font *font) { - free_image(font->img); - free(font); + if (font) { + free_image(font->img); + free(font); + } }