From b6892f5b67782afe05fcd31eaa2d1850bc4e3bc1 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Fri, 11 Oct 2024 15:03:38 -0400 Subject: [PATCH] Let scaninc ignore empty C files --- tools/scaninc/c_file.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/scaninc/c_file.cpp b/tools/scaninc/c_file.cpp index 595f366cbe..c1fe10d374 100644 --- a/tools/scaninc/c_file.cpp +++ b/tools/scaninc/c_file.cpp @@ -33,6 +33,11 @@ CFile::CFile(std::string path) m_size = std::ftell(fp); + if (m_size < 0) + FATAL_ERROR("File size of \"%s\" is less than zero.\n", path.c_str()); + else if (m_size == 0) + return; // Empty file + m_buffer = new char[m_size + 1]; m_buffer[m_size] = 0; @@ -49,7 +54,7 @@ CFile::CFile(std::string path) CFile::~CFile() { - delete[] m_buffer; + if (m_size > 0) delete[] m_buffer; } void CFile::FindIncbins()