diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-05-06 08:04:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-05-06 08:04:23 -0700 |
commit | f26560794e5f0868c9a5035158b69f3c4af8f7b3 (patch) | |
tree | 68292924cf674fc7c51f50a74b60c005273b4ebe /pw.c | |
parent | 1965dfa1525950cf4efc96a16613734d65ea0dc0 (diff) | |
download | pw-f26560794e5f0868c9a5035158b69f3c4af8f7b3.tar.gz pw-f26560794e5f0868c9a5035158b69f3c4af8f7b3.tar.bz2 pw-f26560794e5f0868c9a5035158b69f3c4af8f7b3.zip |
Removal of dubious addch(line, 0) caused crash.
It was a hack to make sure an object is allocated for a null line.
Diffstat (limited to 'pw.c')
-rw-r--r-- | pw.c | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -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++) |