Make free_format_info() cope with NULL pointers.
authorAndre Noll <maan@systemlinux.org>
Sat, 1 Nov 2008 21:55:38 +0000 (22:55 +0100)
committerAndre Noll <maan@systemlinux.org>
Sat, 1 Nov 2008 21:55:38 +0000 (22:55 +0100)
Be liberal with what you take, just as the usual free() function.

format.c

index 6b7a2f6..f6b1f48 100644 (file)
--- a/format.c
+++ b/format.c
@@ -262,11 +262,17 @@ err:
        return ret;
 }
 
+/**
+ * It's OK to pass a \p NULL pointer to this function.
+ */
 void free_format_info(struct format_info *info)
 {
        int i;
        struct format_item *item;
 
+       if (!info)
+               return;
+
        for (i = 0; (item = info->items[i]); i++) {
                if (!item->atom_ptr)
                        free(item->af.cs.string);