Skip to content

Commit 9b34daf

Browse files
committed
raise error instead of assert
1 parent e2dc8ea commit 9b34daf

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lfs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ utf8_filename(lua_State *L, const wchar_t * winfilename, int wsz, char *utf8buff
4343
return luaL_error(L, "convert to utf-8 filename fail");
4444
if (wsz < 0) // not include end \0
4545
return result - 1;
46-
assert(result < sz);
46+
if (result >= sz)
47+
return luaL_error(L, "convert to utf-8 filename : buffer overflow");
4748
utf8buffer[result] = 0;
4849
return result;
4950
}
@@ -62,7 +63,8 @@ windows_filename(lua_State *L, const char * utf8filename, int usz, wchar_t * win
6263
return luaL_error(L, "convert to windows utf-16 filename fail");
6364
if (result < 0)
6465
return result - 1;
65-
assert(result < wsz);
66+
if (result >= wsz)
67+
return luaL_error(L, "convert to windows utf-16 filename : buffer overflow");
6668
winbuffer[result] = 0;
6769
return result;
6870
}

0 commit comments

Comments
 (0)