Browse Source

Check for realloc failures in bflsc driver.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
4c8acdf9dc
  1. 4
      driver-bflsc.c

4
driver-bflsc.c

@ -346,6 +346,8 @@ static bool tolines(struct cgpu_info *bflsc, int dev, char *buf, int *lines, cha
ptr = strdup(buf); ptr = strdup(buf);
while (ptr && *ptr) { while (ptr && *ptr) {
p_items = realloc(p_items, ++p_lines * sizeof(*p_items)); 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; p_items[p_lines-1] = ptr;
ptr = strchr(ptr, '\n'); ptr = strchr(ptr, '\n');
if (ptr) if (ptr)
@ -430,6 +432,8 @@ static bool breakdown(enum breakmode mode, char *buf, int *count, char **firstna
if (comma) if (comma)
*(comma++) = '\0'; *(comma++) = '\0';
p_fields = realloc(p_fields, ++p_count * sizeof(*p_fields)); 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; p_fields[p_count-1] = ptr;
ptr = comma; ptr = comma;
} }

Loading…
Cancel
Save