diff options
author | Kevin McCarthy <kevin@8t8.us> | 2022-03-05 11:17:40 -0800 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2022-03-05 11:17:40 -0800 |
commit | 8babf6c00be0b355f01785bbc16f67712509005a (patch) | |
tree | 96fc50424ed79be49dac0f03810aa3d74395e723 /enter.c | |
parent | 7c8992aa0dc5c17156d09c6c1e0a16100fce7b28 (diff) |
Protect prompt completion memcpy() calls with a NULL check.
The behavior of memcpy() is undefined when dest is NULL, even if n is
0. It's possible to trigger this, somewhat deliberately, for these
two cases, so add a guard check.
Diffstat (limited to 'enter.c')
-rw-r--r-- | enter.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -592,7 +592,8 @@ int _mutt_enter_string (char *buf, size_t buflen, int col, { templen = state->lastchar - i; safe_realloc (&tempbuf, templen * sizeof (wchar_t)); - memcpy (tempbuf, state->wbuf + i, templen * sizeof (wchar_t)); + if (tempbuf) + memcpy (tempbuf, state->wbuf + i, templen * sizeof (wchar_t)); } else BEEP (); @@ -749,7 +750,8 @@ int _mutt_enter_string (char *buf, size_t buflen, int col, { templen = state->lastchar; safe_realloc (&tempbuf, templen * sizeof (wchar_t)); - memcpy (tempbuf, state->wbuf, templen * sizeof (wchar_t)); + if (tempbuf) + memcpy (tempbuf, state->wbuf, templen * sizeof (wchar_t)); } else BEEP (); /* let the user know that nothing matched */ |