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:
@@ -63,12 +63,16 @@ SourceFile::Init(const char* path)
|
|||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st.st_size > kMaxSourceFileSize)
|
if (st.st_size > kMaxSourceFileSize) {
|
||||||
|
close (fd);
|
||||||
return B_FILE_TOO_LARGE;
|
return B_FILE_TOO_LARGE;
|
||||||
|
}
|
||||||
size_t fileSize = st.st_size;
|
size_t fileSize = st.st_size;
|
||||||
|
|
||||||
if (fileSize == 0)
|
if (fileSize == 0) {
|
||||||
|
close (fd);
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
// allocate the content buffer
|
// allocate the content buffer
|
||||||
fFileContent = (char*)malloc(fileSize + 1);
|
fFileContent = (char*)malloc(fileSize + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user