lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I believe the proper way is to mark luaL_error with a no-return specifier? Something like GCC's "__attribute__((noreturn))" would possibly do the trick. Also, this the actual syntactic _expression_ for "functions using setjmp/longjmp".

On Mon, Mar 13, 2017 at 11:54 PM, Jerry Jacobs <> wrote:
I’m using lua 5.3 in a project and clang static analyzer (scan-build) complained about a potential NULL pointer deference in OS lib (loslib.c). The analyzer doesn’t know luaL_error uses setjmp/longjmp and it has its full right to complain. The os_date C function contains this code:

stm = l_gmtime(&t, &tmr);

~~~ snip ~~~

  if (stm == NULL)  /* invalid date? */
    luaL_error(L, "time result cannot be represented in this installation”);

~~~ snip ~~~

problem “passing NULL pointer” ->  setallfields(L, stm);

A simple solution would be just doing a return luaL_error which silences this false-positive.

Kind regards,
Jerry Jacobs

Best regards,
Igor A. Ehrlich