]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: hlua: Fix warnings about uninitialized variables (2)
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 12 Jun 2025 08:49:51 +0000 (10:49 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 12 Jun 2025 08:49:54 +0000 (10:49 +0200)
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

index 87e54f343b5966ae1360872fab3cf93c0945140e..640743366116ef106b0376232b773fe1437270fd 100644 (file)
@@ -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);