hw2: Potential `readline` Memory Leak
Opened this issue · 0 comments
tjhu commented
credit: https://piazza.com/class/ktx3wfc7ufz711?cid=63
Leak location:
https://github.com/antonburtsev/cs143a/blob/7afb45856cc7016e0be1aadf0decc34e9e273a82/hw/hw2-shell/sh_t.c#L40-L47
Potential fix:
if (feof(stdin)) // EOF
{
free(line);
fprintf(stderr, "EOF\n");
exit(EXIT_SUCCESS);
}
Need to verify that the leak indeed occurs and the fix fixes it.