diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c index 2cd965dceab..5d40ac9941f 100644 --- a/lib/libc/gen/getttyent.c +++ b/lib/libc/gen/getttyent.c @@ -207,11 +207,10 @@ endttyent() { int rval; - if (line) { - free(line); - line = NULL; - lbsize = 0; - } + /* + * NB: Don't free `line' because getttynam() + * may still be referencing it + */ if (tf) { rval = (fclose(tf) != EOF); tf = NULL;