From: Rys Sommefeldt Date: Sat, 07 Nov 2009 02:26:17 GMT Subject: Re: [cgit PATCH] Close file descriptor on error in readfile() Message-ID: <4AF4DAC9.3020805@pixeltards.com> In-Reply-To: Steven Noonan wrote: > The above change looks bogus. If fd == -1, you close() it anyway? > Ah, of course, sorry. I'll redo the patch. >> + if (fstat(fd, &st)) { >> + close(fd); >> return errno; >> + } >> if (!S_ISREG(st.st_mode)) >> return EISDIR; >> *buf = xmalloc(st.st_size + 1); >> *size = read_in_full(fd, *buf, st.st_size); >> (*buf)[*size] = '\0'; >> + close(fd); >> return (*size == st.st_size ? 0 : errno); >> } >> -- >> 1.6.5.2 >> -- >> To unsubscribe from this list: send the line "unsubscribe git" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> >> > -- > __________ Information from ESET NOD32 Antivirus, version of virus signature database 4580 (20091106) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com