]> git.tuebingen.mpg.de Git - adu.git/blobdiff - format.c
Make free_format_info() cope with NULL pointers.
[adu.git] / format.c
index 48aa37111c2986d6262686723dd766c9f0ed45ef..f6b1f48d102d9762696de1345fd61cdce9c83c28 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);
@@ -423,6 +429,7 @@ char *format_items(struct format_info *info, union atom_value *values)
                                fi->width, &af->nf, type);
                }
                buf = adu_strcat(buf, val);
+               free(val);
        }
        return buf;
 }