diff --git a/src/apps/debugger/files/SourceFile.cpp b/src/apps/debugger/files/SourceFile.cpp index 479c0141b2..001dcf0e76 100644 --- a/src/apps/debugger/files/SourceFile.cpp +++ b/src/apps/debugger/files/SourceFile.cpp @@ -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);