aboutsummaryrefslogtreecommitdiffstats
path: root/pw.c
diff options
context:
space:
mode:
Diffstat (limited to 'pw.c')
-rw-r--r--pw.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/pw.c b/pw.c
index 3bd77fe..f44ce2a 100644
--- a/pw.c
+++ b/pw.c
@@ -193,6 +193,13 @@ static char *dsgrow(char *str, size_t len)
return ds->str;
}
+static char *dsensure(char *str)
+{
+ if (str)
+ return str;
+ return dsgrow(0, 0);
+}
+
static char *dsdup(char *str)
{
size_t len = strlen(str);
@@ -995,6 +1002,7 @@ int main(int argc, char **argv)
clearerr(stdin);
} else if (ch == '\n') {
nfds = 1;
+ line = dsensure(line);
if ((pw.stat & stat_grep)) {
int i;
for (i = 0; i < ngrep; i++)