PREV INDEX NEXT

Author: Unknown
Subject: free(line) after /dev/null getline() read
Date: Wednesday, 25 Mar 2020, 19:19:40

I have a loop that reads in every file in order. Inside this loop is another while loop that reads in each line. The getline() function is within the while condition. After EOF is reached, I have free(line).

When a null file is opened after a non-empty file, the program goes through the getline() condition for the null file and goes directly to free(line). At this free call, a "double free" error is detected.

Due to the nature of a null file, does getline not allocate space to be free'd after? This would not make sense as running the loop with just a null file does not produce this error.
PREV INDEX NEXT