Simon Josefsson <[EMAIL PROTECTED]> writes: > + if (buf) > + buf[size] = '\0';
The file reading code returns NULL if the file was empty? But the comments makes it sound like it will return xstrdup (""), and that would be more consistent. You might also add a test case, to read from /dev/null. > + if (out) > + rc = fclose (stream); > + else > + { > + /* On failure, preserve the original errno value. */ > + int save_errno = errno; > + rc = fclose (stream); > + errno = save_errno; > + } > + > + if (rc != 0) > + { > + int save_errno = errno; > + free (out); > + errno = save_errno; > + return NULL; > + } The following replacement code is a bit clearer, at least to my eyes: save_errno = errno; if (fclose (stream) != 0) { if (out) { save_errno = errno; free (out); } errno = save_errno; return NULL; }