summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--atobm.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/atobm.c b/atobm.c
index 90440ac..7d25906 100644
--- a/atobm.c
+++ b/atobm.c
@@ -243,7 +243,7 @@ doit (FILE *fp,
*newline = '\0';
len = strlen (cp);
- if (width == 0) {
+ if (head == NULL) {
width = len;
padded = ((width & 7) != 0);
bytes_per_scanline = (len + 7) / 8;
@@ -257,7 +257,7 @@ doit (FILE *fp,
fprintf (stderr,
"%s: line %d is %d characters wide instead of %d\n",
ProgramName, lineno, len, width);
- return;
+ goto bail;
}
if (slist->used + 1 >= slist->allocated) {
@@ -266,8 +266,7 @@ doit (FILE *fp,
if (!slist) {
fprintf (stderr, "%s: unable to allocate scan list\n", ProgramName);
- free(old);
- return;
+ goto bail;
}
}
@@ -308,5 +307,11 @@ doit (FILE *fp,
}
}
printf (" };\n");
+ bail:
+ for (slist = head; slist != NULL; slist = head) {
+ head = slist->next;
+ free(slist->scanlines);
+ free(slist);
+ }
return;
}