From 2c3f3eaaed505b6d9781282f571c18b25a06e1cf Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 12 Jun 2025 10:49:51 +0200 Subject: [PATCH] BUILD: hlua: Fix warnings about uninitialized variables (2) It was still failing on Ubuntu-24.04 with GCC+ASAN. So, instead of understand the code path the compiler followed to report uninitialized variables, let's init them now. No backport needed. --- src/hlua.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/hlua.c b/src/hlua.c index 87e54f343..640743366 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -5300,10 +5300,10 @@ __LJMP static int hlua_applet_tcp_getline_yield(lua_State *L, int status, lua_KC { struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_tcp(L, 1)); int ret; - const char *blk1; - size_t len1; - const char *blk2; - size_t len2; + const char *blk1 = NULL; + size_t len1 = 0; + const char *blk2 = NULL; + size_t len2 = 0; /* Read the maximum amount of data available. */ ret = applet_getline_nc(luactx->appctx, &blk1, &len1, &blk2, &len2); @@ -5355,10 +5355,10 @@ __LJMP static int hlua_applet_tcp_recv_try(lua_State *L) size_t len = MAY_LJMP(luaL_checkinteger(L, 2)); int exp_date = MAY_LJMP(luaL_checkinteger(L, 3)); int ret; - const char *blk1; - size_t len1; - const char *blk2; - size_t len2; + const char *blk1 = NULL; + size_t len1 = 0; + const char *blk2 = NULL; + size_t len2 = 0; /* Read the maximum amount of data available. */ ret = applet_getblk_nc(luactx->appctx, &blk1, &len1, &blk2, &len2); @@ -5414,11 +5414,12 @@ __LJMP static int hlua_applet_tcp_recv_try(lua_State *L) len -= len1; /* Copy the second block. */ - if (len2 > len) - len2 = len; - if (len2) + if (len2) { + if (len2 > len) + len2 = len; luaL_addlstring(&luactx->b, blk2, len2); - len -= len2; + len -= len2; + } applet_skip_input(luactx->appctx, len1+len2);