From d1469df96b220ed96a78f13d6301151beeb3fe6c Mon Sep 17 00:00:00 2001 From: dzaima Date: Wed, 31 Jul 2024 03:03:11 +0300 Subject: [PATCH] fix out-of-bounds load on empty replxx line `chars[0] == ')'` was branching on empty data; not UB due to custom heap usage and the code that does run is harmless, but still hit under valgrind --- src/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.c b/src/main.c index 941e1cff..3ad8a205 100644 --- a/src/main.c +++ b/src/main.c @@ -260,6 +260,8 @@ static NOINLINE i64 readInt(char** p) { return c; } NOINLINE void completion_impl(const char* inp, void* res, bool hint, int* dist) { + if (!*inp) return; + CATCH_OOM(return) B inpB = toC32Any(utf8Decode0(inp)); u32* chars = c32any_ptr(inpB);