mirror of
https://github.com/lua/lua.git
synced 2025-07-04 07:03:24 +00:00
Added test for NULL in string.format("%p")
ISO C states that standard library functions should not be called with NULL arguments, unless stated otherwise. 'sprintf' does not state otherwise, and it doesn't hurt to be on the safe side.
This commit is contained in:
parent
3747487320
commit
e0cbaa50fa
1 changed files with 2 additions and 0 deletions
|
@ -1271,6 +1271,8 @@ static int str_format (lua_State *L) {
|
|||
}
|
||||
case 'p': {
|
||||
const void *p = lua_topointer(L, arg);
|
||||
if (p == NULL)
|
||||
p = "(null)"; /* NULL not a valid parameter in ISO C 'printf' */
|
||||
nb = l_sprintf(buff, maxitem, form, p);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue