Commit 4c8acdf9dc7716126ca10e1c31a6578d79bd3949

Con Kolivas 2013-04-26T12:44:01

Check for realloc failures in bflsc driver.

diff --git a/driver-bflsc.c b/driver-bflsc.c
index 1fbabba..b019b8f 100644
--- a/driver-bflsc.c
+++ b/driver-bflsc.c
@@ -346,6 +346,8 @@ static bool tolines(struct cgpu_info *bflsc, int dev, char *buf, int *lines, cha
 	ptr = strdup(buf);
 	while (ptr && *ptr) {
 		p_items = realloc(p_items, ++p_lines * sizeof(*p_items));
+		if (unlikely(!p_items))
+			quit(1, "Failed to realloc p_items in tolines");
 		p_items[p_lines-1] = ptr;
 		ptr = strchr(ptr, '\n');
 		if (ptr)
@@ -430,6 +432,8 @@ static bool breakdown(enum breakmode mode, char *buf, int *count, char **firstna
 		if (comma)
 			*(comma++) = '\0';
 		p_fields = realloc(p_fields, ++p_count * sizeof(*p_fields));
+		if (unlikely(!p_fields))
+			quit(1, "Failed to realloc p_fields in breakdown");
 		p_fields[p_count-1] = ptr;
 		ptr = comma;
 	}