]> git.tuebingen.mpg.de Git - adu.git/blobdiff - format.c
format_items(): Check for NULL pointers.
[adu.git] / format.c
index 6b7a2f6e2186b8850f2e04abaecff9cb88b3a625..a3a01ba1ca18b230298f5b349cf8f1737a0d49f6 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);
@@ -395,6 +401,8 @@ char *format_items(struct format_info *info, union atom_value *values)
        int i;
        char *buf = NULL;
 
+       if (!info)
+               return NULL;
        for (i = 0; info->items[i]; i++) {
                struct atom *a;
                struct format_item *fi = info->items[i];