[PATCH] lib: fwts_tag: handle out of memory failure

Colin King colin.king at canonical.com
Fri Mar 2 10:01:02 UTC 2012


From: Colin Ian King <colin.king at canonical.com>

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/lib/src/fwts_tag.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/lib/src/fwts_tag.c b/src/lib/src/fwts_tag.c
index 76c84ec..24e0b53 100644
--- a/src/lib/src/fwts_tag.c
+++ b/src/lib/src/fwts_tag.c
@@ -158,11 +158,13 @@ char *fwts_tag_list_to_str(fwts_list *taglist)
 		len += taglen + 1;
 
 		if (str) {
-			str = realloc(str, len);
+			if ((str = realloc(str, len)) == NULL)
+				return NULL;
 			strcat(str, " ");
 			strcat(str, tag);
 		} else {
-			str = malloc(len);
+			if ((str = malloc(len)) == NULL)
+				return NULL;
 			strcpy(str, tag);
 		}
 	}
-- 
1.7.9





More information about the fwts-devel mailing list