Remove warnings from lcl.c and lfile.c by fixing some issues

This commit is contained in:
Jeremy Baxter 2023-07-09 16:19:37 +12:00
parent f2ff542bcb
commit 612a22678b
2 changed files with 7 additions and 7 deletions

View file

@ -38,10 +38,10 @@
static int
file_basename(lua_State *L)
{
const char *path; /* parameter 1 (string) */
const char *ret;
char *path; /* parameter 1 (string) */
path = luaL_checkstring(L, 1);
path = strndup(luaL_checkstring(L, 1), lua_rawlen(L, 1));
ret = basename(path);
if (ret == NULL && errno == ENAMETOOLONG) /* check if path is too long */
@ -70,10 +70,10 @@ file_basename(lua_State *L)
static int
file_dirname(lua_State *L)
{
const char *path; /* parameter 1 (string) */
const char *ret;
char *path; /* parameter 1 (string) */
path = luaL_checkstring(L, 1);
path = strndup(luaL_checkstring(L, 1), lua_rawlen(L, 1));
ret = dirname(path);
if (ret == NULL && errno == ENAMETOOLONG) /* check if path is too long */