From e99dbb858ecd35dada1ba0da3339cf9ca2722819 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Fri, 16 Sep 2016 21:55:39 +0000 Subject: [PATCH] Fix undefined behavior: null pointer passed as argument which is declared to never be null git-svn-id: https://svn.eduke32.com/eduke32@5868 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/defs.c | 3 ++- polymer/eduke32/source/premap.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index 9f92d4acc..e056df7d2 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -3491,7 +3491,8 @@ int32_t loaddefinitionsfile(const char *fn) DO_FREE_AND_NULL(faketilebuffer); faketilebuffersiz = 0; - qsort(usermaphacks, num_usermaphacks, sizeof(usermaphack_t), compare_usermaphacks); + if (usermaphacks != NULL) + qsort(usermaphacks, num_usermaphacks, sizeof(usermaphack_t), compare_usermaphacks); if (!script) return -1; diff --git a/polymer/eduke32/source/premap.c b/polymer/eduke32/source/premap.c index 1e9a50975..121e15b91 100644 --- a/polymer/eduke32/source/premap.c +++ b/polymer/eduke32/source/premap.c @@ -1711,7 +1711,7 @@ static void G_LoadMapHack(char *outbuf, const char *filename) append_ext_UNSAFE(outbuf, ".mhk"); - if (G_TryMapHack(outbuf)) + if (G_TryMapHack(outbuf) && usermaphacks != NULL) { usermaphack_t *pMapInfo = (usermaphack_t*)bsearch( &g_loadedMapHack, usermaphacks, num_usermaphacks, sizeof(usermaphack_t),