From 3ea3a9b43b75c729c0e5ef88b4f7792ed646989c Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sat, 4 Jun 2016 16:19:57 +0200 Subject: [PATCH] src/system/localize.cpp Undefined allocation of 0 bytes Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/eb2c84434aa0d2c81b6a2f6949c03595e36c5cc8 Author: Jacek Jendrzej Date: 2016-06-04 (Sat, 04 Jun 2016) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/system/localize.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/system/localize.cpp b/src/system/localize.cpp index 607f7b95f..63f562437 100644 --- a/src/system/localize.cpp +++ b/src/system/localize.cpp @@ -223,17 +223,18 @@ CLocaleManager::loadLocale_ret_t CLocaleManager::loadLocale(const char * const l fclose(fd); if(buf) free(buf); - char *_mem = (char *) realloc(*mem, memp - *mem); - if (_mem) { - if (_mem != *mem) { - // most likely doesn't happen - for(unsigned int i = 1; i < sizeof(locale_real_names)/sizeof(const char *); i++) - if (loadData[i] != locale_real_names[i]) - loadData[i] -= *mem - _mem; - *mem = _mem; + if(memp - *mem > 0){ + char *_mem = (char *) realloc(*mem, memp - *mem); + if (_mem) { + if (_mem != *mem) { + // most likely doesn't happen + for(unsigned int i = 1; i < sizeof(locale_real_names)/sizeof(const char *); i++) + if (loadData[i] != locale_real_names[i]) + loadData[i] -= *mem - _mem; + *mem = _mem; + } } } - for (unsigned j = 1; j < (sizeof(locale_real_names)/sizeof(const char *)); j++) if (loadData[j] == locale_real_names[j]) {