Skip to content

Commit ee35eee

Browse files
committed
lib: fix invalid free in config parsing
1 parent 2d97729 commit ee35eee

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/conf.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested)
328328
FILE *fp;
329329
size_t len, nlines = 0;
330330
ssize_t rd;
331-
char *line = NULL;
331+
char *linebuf = NULL;
332332
int rv = 0;
333333
int size, rs;
334334
char *dir;
@@ -341,7 +341,8 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested)
341341

342342
xbps_dbg_printf("Parsing configuration file: %s\n", path);
343343

344-
while ((rd = getline(&line, &len, fp)) != -1) {
344+
while ((rd = getline(&linebuf, &len, fp)) != -1) {
345+
char *line = linebuf;
345346
char *val = NULL;
346347
size_t vallen;
347348

@@ -461,7 +462,7 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested)
461462
break;
462463
}
463464
}
464-
free(line);
465+
free(linebuf);
465466
fclose(fp);
466467

467468
return rv;

0 commit comments

Comments
 (0)