Does a memory leak exist?
<p>I'm looking at an assignment question. With it there is this piece of C code:</p>

<pre><code>char* read_from_file (const char* filename, size_t length) {
    return NULL;
}

void main (int argc, char **argv) {
    char* buff;
    if ((buff = read_from_file("test1.txt", 10)) == NULL) {
       fprintf(stdout, "Failed to read test1.txt\n");
    } else {
       fprintf(stdout, "buff is: %s\n", buff);
    }
    if ((buff = read_from_file("test2.txt", 10)) == NULL) {
       fprintf(stdout, "Failed to read test2.txt\n");
    } else {
       fprintf(stdout, "buff is: %s\n", buff);
    }
}
</code></pre>

<p>The question says that memory is leaking. It tells me to insert <code>free(buff)</code> statements in the main program to suppress memory leaking. I always thought that memory leaks were normally associated with dynamic memory allocation. As well, shouldn't <code>free()</code> be used to free a pointer to a memory block previously allocated with <code>malloc()</code>, etc.</p>

<p>Is there something I'm missing with this assignment question?</p>

<p>NOTE: I'm just looking for advice and insights.</p>