You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.5 KiB

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