Avoid leaking a file descriptor on error. Thanks PovAddict for running cppcheck.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40037 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol
2010-12-29 20:05:24 +00:00
parent 4517bee6c0
commit d074928c03
+6 -2
View File
@@ -63,12 +63,16 @@ SourceFile::Init(const char* path)
return errno;
}
if (st.st_size > kMaxSourceFileSize)
if (st.st_size > kMaxSourceFileSize) {
close (fd);
return B_FILE_TOO_LARGE;
}
size_t fileSize = st.st_size;
if (fileSize == 0)
if (fileSize == 0) {
close (fd);
return B_BAD_VALUE;
}
// allocate the content buffer
fFileContent = (char*)malloc(fileSize + 1);