X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=blobdiff_plain;f=format.c;h=bcdbff9ff425df1783975cf8ac62a64ab28fa40e;hp=48aa37111c2986d6262686723dd766c9f0ed45ef;hb=6dc3d02ae5959a4ec5f3de4765d7440a580ff3e1;hpb=bd06800e612996d0c4b4c2ec52646a842d301452 diff --git a/format.c b/format.c index 48aa371..bcdbff9 100644 --- a/format.c +++ b/format.c @@ -259,14 +259,21 @@ err: } free(info->items); free(info); + *result = NULL; 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 +402,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]; @@ -423,6 +432,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; }