Trivial fix to make sure we allocate memory before trying to access
where a pointer points.
while (fgets(linebuf, sizeof(linebuf), file)) {
struct filterlist *filter;
+ filter = malloc(sizeof(struct filterlist));
+ if (!filter) {
+ ohshite(_("Error allocating memory for filter entry"));
+ }
+
if (linebuf[0] == '#' || linebuf[0] == '\n') {
continue;
}
filter->positive = 0;
} else {
warningf(_("Invalid filter line: `%.255s'"), linebuf);
- }
-
- filter = malloc(sizeof(struct filterlist));
- if (!filter) {
- ohshite(_("Error allocating memory for filter entry"));
+ free(filter);
+ continue;
}
filter->filterstring = malloc(strlen(linebuf));