ref: 18cffd69099077966d80b47aad16bf5f7f6b2e5b
parent: 433b9cd26eb5d27977eb8cde6bb1c019606e0ffa
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Nov 1 13:45:02 EDT 2021
cc1: Allow empty fname in setloc() so setloc() must support an empty fname parameter for that case.
--- a/src/cmd/cc/cc1/lex.c
+++ b/src/cmd/cc/cc1/lex.c
@@ -73,13 +73,16 @@
{
size_t len;
- if ((len = strlen(fname)) >= FILENAME_MAX)
- die("cc1: %s: file name too long", fname);
- memmove(filenam, fname, len);
- filenam[len] = '\0';
+ if (fname) {
+ if ((len = strlen(fname)) >= FILENAME_MAX)
+ die("cc1: %s: file name too long", fname);
+ memmove(filenam, fname, len);
+ filenam[len] = '\0';
- free(input->filenam);
- input->filenam = xstrdup(fname);
+ free(input->filenam);
+ input->filenam = xstrdup(fname);
+ }
+
lineno = input->lineno = line;
}