summaryrefslogtreecommitdiffstats
path: root/enter.c
diff options
context:
space:
mode:
authorKevin McCarthy <kevin@8t8.us>2022-03-05 11:17:40 -0800
committerKevin McCarthy <kevin@8t8.us>2022-03-05 11:17:40 -0800
commit8babf6c00be0b355f01785bbc16f67712509005a (patch)
tree96fc50424ed79be49dac0f03810aa3d74395e723 /enter.c
parent7c8992aa0dc5c17156d09c6c1e0a16100fce7b28 (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.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/enter.c b/enter.c
index 1daa10b2..f09dd265 100644
--- a/enter.c
+++ b/enter.c
@@ -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 */