Closed jdujava closed 4 months ago
That appears to be a message from ubsan, at the indicated line browser/complete.c:139:5
there is a call to memcpy, the first argument is allocated the line before using mutt_mem_realloc
. With the buffer being empty the size passed to mutt_mem_realloc
is 0, which results in memcpy
using a NULL pointer as the destination buffer, since the size passed to memcpy
is also 0 I don't believe particularly disastrous is likely to happen, but it is undefined behaviour to pass a NULL pointer to memcpy
.
I'm not entirely certain how this complete function is supposed to function, but I believe it would be relatively simple to add a simple check for the case of 0 length.
Thanks for the bug report; I haven't had a chance to investigate yet.
As you've already noted, a simple check would stop the problem. I'll certainly add something like that to the code before the next release.
However...
What I'd love to know is why we're getting a NULL
there.
If someone has a bit of time to dig into the code, it'd really be appreciated.
Feel free to ask lots of questions here, or on IRC: #neomutt
on irc.libera.chat
(web client)
Thanks!
I can't seem reproduce this.
With ubsan enabled I actually get a different error on every completion, not just empty. Maybe because I'm on macOS.
editor/functions.c:187:12: runtime error: call to function complete_file_simple through pointer to incorrect function type 'enum FunctionRetval (*)(struct EnterWindowData *, int)'
complete.c:114: note: complete_file_simple defined here
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior editor/functions.c:187:12
Which I can fix with:
diff --git a/browser/complete.c b/browser/complete.c
index f6dca66e1..673668a44 100644
--- a/browser/complete.c
+++ b/browser/complete.c
@@ -110,7 +110,7 @@ int complete_file_mbox(struct EnterWindowData *wdata, int op)
/**
* complete_file_simple - Complete a filename - Implements ::complete_function_t - @ingroup complete_api
*/
-int complete_file_simple(struct EnterWindowData *wdata, int op)
+enum FunctionRetval complete_file_simple(struct EnterWindowData *wdata, int op)
{
if (!wdata || ((op != OP_EDITOR_COMPLETE) && (op != OP_EDITOR_COMPLETE_QUERY)))
return FR_NO_ACTION;
I can no longer reproduce this in NeoMutt 20240425
.
Should I close this now?
I can no longer reproduce this in
NeoMutt 20240425
.
🎉
Should I close this now?
Thanks for getting back to us! I'll close this.
Expected Behaviour
Invoking
complete-query
insave-entry
(called from Attachments view) shouldn't emit runtime error message.Actual Behaviour
When pressing
<Tab>
(trying to invoke complete via bindingbind editor <Tab> complete-query
) on an emptysave-entry
prompt results in following message (butneomutt
doesn't crash)Steps to Reproduce
v
enterAttachments
view on any messages
opensave-entry
prompt./
inserted, so delete it to obtain an empty promptcomplete-query
(for example with<Tab>
and binding mentioned earlier) results in the error messageHow often does this happen?
My limited testing suggests that it happens always, but only on the first try after opening
neomutt
.When did it start to happen?
I noticed it already on the previous release NeoMutt 2023-12-21.
NeoMutt Version