From f70b292af4612e44241574b3ac6cd069eafed337 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 30 Jun 2009 20:19:27 +0200 Subject: [PATCH] make_attribute_lines(): Check return value of (). As get_attribute_text() might fail, we have to check its return value. --- aft.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/aft.c b/aft.c index 7027e7f9..1f7332c8 100644 --- a/aft.c +++ b/aft.c @@ -723,18 +723,19 @@ static void get_duration_buf(int seconds, char *buf, struct ls_options *opts) } } -static char *make_attribute_lines(const char *att_bitmap, struct afs_info *afsi) +static int make_attribute_lines(const char *att_bitmap, struct afs_info *afsi, + char **result) { - char *att_text, *att_lines; + char *att_text; + int ret = get_attribute_text(&afsi->attributes, " ", &att_text); - get_attribute_text(&afsi->attributes, " ", &att_text); - if (!att_text) - return para_strdup(att_bitmap); - att_lines = make_message("%s: %s\n%s: %s", + if (ret < 0) + return ret; + *result = make_message("%s: %s\n%s: %s", status_item_list[SI_ATTRIBUTES_BITMAP], att_bitmap, status_item_list[SI_ATTRIBUTES_TXT], att_text); free(att_text); - return att_lines; + return 1; } static char *make_lyrics_lines(struct afs_info *afsi) @@ -878,7 +879,9 @@ static int print_list_item(struct ls_data *d, struct ls_options *opts, goto out; } hash_to_asc(d->hash, asc_hash); - att_lines = make_attribute_lines(att_buf, afsi); + ret = make_attribute_lines(att_buf, afsi, &att_lines); + if (ret < 0) + goto out; lyrics_lines = make_lyrics_lines(afsi); image_lines = make_image_lines(afsi); filename_lines = make_filename_lines(d->path, opts->flags); -- 2.39.5