FreeBSD Bugzilla – Attachment 237479 Details for
Bug 267221
[patch] Regression in recently merged file-5.43
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
rollback of original commit that introduced the problem
file.c.diff (text/plain), 1.47 KB, created by
Eugene Grosbein
on 2022-10-20 09:37:54 UTC
(
hide
)
Description:
rollback of original commit that introduced the problem
Filename:
MIME Type:
Creator:
Eugene Grosbein
Created:
2022-10-20 09:37:54 UTC
Size:
1.47 KB
patch
obsolete
>--- contrib/file/src/file.c.orig 2022-10-17 12:50:30.934580000 +0300 >+++ contrib/file/src/file.c 2022-10-20 12:32:27.582266000 +0300 >@@ -512,49 +512,35 @@ unwrap(struct magic_set *ms, const char *fn) > size_t llen = 0; > int wid = 0, cwid; > int e = 0; >- size_t fi = 0, fimax = 100; >- char **flist = CAST(char **, malloc(sizeof(*flist) * fimax)); > >- if (flist == NULL) >-out: file_err(EXIT_FAILURE, "Cannot allocate memory for file list"); >- >- if (strcmp("-", fn) == 0) >+ if (strcmp("-", fn) == 0) { > f = stdin; >- else { >+ wid = 1; >+ } else { > if ((f = fopen(fn, "r")) == NULL) { > file_warn("Cannot open `%s'", fn); > return 1; > } >+ >+ while ((len = getline(&line, &llen, f)) > 0) { >+ if (line[len - 1] == '\n') >+ line[len - 1] = '\0'; >+ cwid = file_mbswidth(ms, line); >+ if (cwid > wid) >+ wid = cwid; >+ } >+ >+ rewind(f); > } > > while ((len = getline(&line, &llen, f)) > 0) { > if (line[len - 1] == '\n') > line[len - 1] = '\0'; >- if (fi >= fimax) { >- fimax += 100; >- char **nf = CAST(char **, >- realloc(flist, fimax * sizeof(*flist))); >- if (nf == NULL) >- goto out; >- flist = nf; >- } >- flist[fi++] = line; >- cwid = file_mbswidth(ms, line); >- if (cwid > wid) >- wid = cwid; >- line = NULL; >- llen = 0; >+ e |= process(ms, line, wid); > } > >- fimax = fi; >- for (fi = 0; fi < fimax; fi++) { >- e |= process(ms, flist[fi], wid); >- free(flist[fi]); >- } >- free(flist); >- >- if (f != stdin) >- (void)fclose(f); >+ free(line); >+ (void)fclose(f); > return e; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 267221
:
237479
|
237669