ca353879b2bff5e6e34031b1d8e1f3a33f6b5e3a
[openwrt-packages.git] /
1 commit 8019e88dd1ac73a3baa71e9acfbc1b7a3fbc7442
2 Author: Willy Tarreau <w@1wt.eu>
3 Date:   Tue Oct 16 17:37:12 2018 +0200
4
5     BUILD: lua: silence some compiler warnings about potential null derefs (#2)
6     
7     Here we make sure that appctx is always taken from the unchecked value
8     since we know it's an appctx, which explains why it's immediately
9     dereferenced. A missing test was added to ensure that task_new() does
10     not return a NULL.
11     
12     This may be backported to 1.8.
13     
14     (cherry picked from commit e09101e8d92b0c0ef8674fbc791e309112ab7f1c)
15     Signed-off-by: Willy Tarreau <w@1wt.eu>
16
17 diff --git a/src/hlua.c b/src/hlua.c
18 index 64102e8a..ad9238ef 100644
19 --- a/src/hlua.c
20 +++ b/src/hlua.c
21 @@ -2361,7 +2361,7 @@ __LJMP static int hlua_socket_connect_yield(struct lua_State *L, int status, lua
22                 return 2;
23         }
24  
25 -       appctx = objt_appctx(s->si[0].end);
26 +       appctx = __objt_appctx(s->si[0].end);
27  
28         /* Check for connection established. */
29         if (appctx->ctx.hlua_cosocket.connected) {
30 @@ -2473,7 +2473,7 @@ __LJMP static int hlua_socket_connect(struct lua_State *L)
31         }
32  
33         hlua = hlua_gethlua(L);
34 -       appctx = objt_appctx(s->si[0].end);
35 +       appctx = __objt_appctx(s->si[0].end);
36  
37         /* inform the stream that we want to be notified whenever the
38          * connection completes.
39 @@ -5693,6 +5693,9 @@ static int hlua_register_task(lua_State *L)
40                 WILL_LJMP(luaL_error(L, "lua out of memory error."));
41  
42         task = task_new(MAX_THREADS_MASK);
43 +       if (!task)
44 +               WILL_LJMP(luaL_error(L, "Lua out of memory error."));
45 +
46         task->context = hlua;
47         task->process = hlua_process_task;
48  
git clone https://git.99rst.org/PROJECT