ref: 7835cef164631789c1b631bc240bc82ba9438b52
parent: 4e0c1829c7b5e17414f453fc22e6533978632d4c
author: Ali Gholami Rudi <[email protected]>
date: Wed Oct 16 15:36:15 EDT 2013
in: do not fclose(stdin), even if it has been renamed with .lf
--- a/in.c
+++ b/in.c
@@ -58,7 +58,7 @@
buf->fin = fin;
buf->lnum = 1;
if (path)
- snprintf(buf->path, sizeof(buf->path) - 1, "%s", path);
+ snprintf(buf->path, sizeof(buf->path), "%s", path);
}
}
@@ -68,7 +68,7 @@
while (cur && !cur->fin)
cur = cur->prev;
if (path)
- strcpy(cur->path, path);
+ snprintf(cur->path, sizeof(cur->path), "%s", path);
cur->lnum = lnum;
}
@@ -84,7 +84,7 @@
buf = buf->prev;
if (old->args)
args_free(old->args);
- if (old->fin && old->path[0])
+ if (old->fin && old->fin != stdin)
fclose(old->fin);
free(old->buf);
free(old);