Skip to content

Commit f28f577

Browse files
committed
Address review comments
1 parent 31d91e0 commit f28f577

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/lua_sysctl.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@
6161
#include "lauxlib.h"
6262
#include "lualib.h"
6363

64+
/*
65+
* lua 5.3+ define LUA_MAXINTEGER, but lua 5.2 does not. See
66+
* https://www.lua.org/manual/5.2/manual.html#lua_Integer
67+
*/
68+
#ifndef LUA_MAXINTEGER
69+
#define LUA_MAXINTEGER PTRDIFF_MAX
70+
#endif
6471

6572
/* NOTE: our signature of oidfmt differ from sysctl.c because we check for the
6673
buffer's size */
@@ -514,7 +521,7 @@ luaA_sysctl_get(lua_State *L)
514521
else
515522
lua_pushinteger(L, mv);
516523
} else {
517-
if (intlen > sizeof(lua_Integer))
524+
if (umv > LUA_MAXINTEGER)
518525
lua_pushnumber(L, umv);
519526
else
520527
lua_pushinteger(L, (lua_Integer)(umv));

0 commit comments

Comments
 (0)