[CMD] Add missing memory allocation NULL checks (#161). CORE-8304

Adapted from a patch by Jacob S. Preciado.

Bring also the code suggestions emitted during review.
This commit is contained in:
Hermès Bélusca-Maïto 2017-12-03 18:49:41 +01:00
parent 73798d2e71
commit 3f892a8d6b
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
16 changed files with 293 additions and 147 deletions

View file

@ -245,7 +245,7 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
#ifdef FEATURE_HISTORY
/* add to the history */
if (str[0])
History (0, str);
History(0, str);
#endif /*FEATURE_HISTORY*/
str[charcount++] = _T('\n');
str[charcount] = _T('\0');
@ -479,7 +479,7 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
#ifdef FEATURE_HISTORY
/* add to the history */
if (str[0])
History (0, str);
History(0, str);
#endif
str[charcount++] = _T('\n');
str[charcount] = _T('\0');
@ -503,7 +503,7 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
#ifdef FEATURE_HISTORY
/* get previous command from buffer */
ClearCommandLine (str, maxlen, orgx, orgy);
History (-1, str);
History(-1, str);
current = charcount = _tcslen (str);
if (((charcount + orgx) / maxx) + orgy > maxy - 1)
orgy += maxy - ((charcount + orgx) / maxx + orgy + 1);
@ -516,7 +516,7 @@ BOOL ReadCommand(LPTSTR str, INT maxlen)
#ifdef FEATURE_HISTORY
/* get next command from buffer */
ClearCommandLine (str, maxlen, orgx, orgy);
History (1, str);
History(1, str);
current = charcount = _tcslen (str);
if (((charcount + orgx) / maxx) + orgy > maxy - 1)
orgy += maxy - ((charcount + orgx) / maxx + orgy + 1);