diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c index a4b31aa54f7d..2cd965dceab5 100644 --- a/lib/libc/gen/getttyent.c +++ b/lib/libc/gen/getttyent.c @@ -82,11 +82,11 @@ getttyent() while (!index(p, '\n')) { i = strlen(p); lbsize += MALLOCCHUNK; - if ((line = realloc(line, lbsize)) == NULL) { + if ((p = realloc(line, lbsize)) == NULL) { (void)endttyent(); return (NULL); } - p = line; + line = p; if (!fgets(&line[i], lbsize - i, tf)) return (NULL); }