BUG/MINOR: hlua: fix invalid errmsg use in hlua_init()
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 10 Apr 2025 15:35:53 +0000 (17:35 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Tue, 15 Apr 2025 20:27:00 +0000 (22:27 +0200)
errmsg is used with memprintf and friends, thus it must be NULL
initialized before being passed to memprintf, else invalid read will
occur.

However in hlua_init() the errmsg value isn't initialized, let's fix that

This is really minor because it would only cause issue on error paths,
yet it may be backported to all stable versions, just in case.

(cherry picked from commit ea3c96369f4a5def90888c9207cd88010d473eb4)
Signed-off-by: Aurelien DARRAGON <adarragon@haproxy.com>
(cherry picked from commit 50838c51a97113d0c9b95d22b4312c9a80a0409d)
Signed-off-by: Aurelien DARRAGON <adarragon@haproxy.com>

src/hlua.c

index 1b390d7..b971630 100644 (file)
@@ -14290,7 +14290,7 @@ lua_State *hlua_init_state(int thread_num)
 
 void hlua_init(void) {
        int i;
-       char *errmsg;
+       char *errmsg = NULL;
 #ifdef USE_OPENSSL
        struct srv_kw *kw;
        int tmp_error;