Skip to content

Commit

Permalink
fix undefined behaviours and jpeg crash on non-windows platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
nillerusr committed Oct 8, 2023
1 parent 047f8b1 commit 5a4d0b7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion common/imageutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ extern void longjmp( jmp_buf, int ) __attribute__((noreturn));
#define JPEGLIB_USE_STDIO
#if ANDROID
#include "android/jpeglib/jpeglib.h"
#else
#elif defined WIN32
#include "jpeglib/jpeglib.h"
#else
#include <jpeglib.h>
#endif

#undef JPEGLIB_USE_STDIO


Expand Down
2 changes: 1 addition & 1 deletion filesystem/basefilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4203,7 +4203,7 @@ bool CBaseFileSystem::FindNextFileInVPKOrPakHelper( FindData_t *pFindData )
{
V_strncpy( pFindData->findData.cFileName, V_UnqualifiedFileName( pFindData->m_fileMatchesFromVPKOrPak[0] ), sizeof( pFindData->findData.cFileName ) );
pFindData->findData.dwFileAttributes = 0;
delete pFindData->m_fileMatchesFromVPKOrPak.Head();
delete[] pFindData->m_fileMatchesFromVPKOrPak.Head();
pFindData->m_fileMatchesFromVPKOrPak.RemoveMultipleFromHead( 1 );

return true;
Expand Down
3 changes: 3 additions & 0 deletions vgui2/vgui_controls/FileOpenDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,9 @@ void FileOpenDialog::OnOpen()
char pFileName[MAX_PATH];
GetSelectedFileName( pFileName, sizeof( pFileName ) );

if( !pFileName[0] )
return;

int nLen = Q_strlen( pFileName );
bool bSpecifiedDirectory = ( pFileName[nLen-1] == '/' || pFileName[nLen-1] == '\\' ) && (!IsOSX() || ( IsOSX() && !Q_stristr( pFileName, ".app" ) ) );
Q_StripTrailingSlash( pFileName );
Expand Down
4 changes: 2 additions & 2 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ def define_platform(conf):
'_DLL_EXT=.so'
])

# if conf.env.DEST_OS != 'win32':
if conf.env.DEST_OS != 'win32':
conf.define('NO_MEMOVERRIDE_NEW_DELETE', 1)
# conf.define('NO_MALLOC_OVERRIDE', 1)
# conf.define('NO_MEMOVERRIDE_NEW_DELETE', 1)

if conf.options.DEBUG_ENGINE:
conf.env.append_unique('DEFINES', [
Expand Down

0 comments on commit 5a4d0b7

Please sign in to comment.