mirror of
https://github.com/d0k3/GodMode9.git
synced 2026-05-30 22:36:55 +00:00
Fixing LUA MemTextViewer calls.
This commit is contained in:
parent
35cf7898cc
commit
27c5a5c4f3
@ -206,12 +206,16 @@ static int ui_show_text_viewer(lua_State* L) {
|
||||
|
||||
// validate text ourselves so we can return a better error
|
||||
// MemTextViewer calls ShowPrompt if it's bad, and i don't want that
|
||||
|
||||
if (len >= STD_BUFFER_SIZE) {
|
||||
return luaL_error(L, "text is too large");
|
||||
}
|
||||
|
||||
if (!(ValidateText(text, len))) {
|
||||
return luaL_error(L, "text validation failed");
|
||||
}
|
||||
|
||||
if (!(MemTextViewer(text, len, 1, false))) {
|
||||
if (!(MemTextViewer(text, len, 1, false, 0, NULL))) {
|
||||
return luaL_error(L, "failed to run MemTextViewer");
|
||||
}
|
||||
|
||||
@ -225,6 +229,11 @@ static int ui_show_file_text_viewer(lua_State* L) {
|
||||
// validate text ourselves so we can return a better error
|
||||
// MemTextViewer calls ShowPrompt if it's bad, and i don't want that
|
||||
// and FileTextViewer calls the above function
|
||||
|
||||
size_t fileSize = FileGetSize(path);
|
||||
if (fileSize >= STD_BUFFER_SIZE) {
|
||||
return luaL_error(L, "text file is too large");
|
||||
}
|
||||
|
||||
char* text = malloc(STD_BUFFER_SIZE);
|
||||
if (!text) {
|
||||
@ -233,16 +242,14 @@ static int ui_show_file_text_viewer(lua_State* L) {
|
||||
|
||||
// TODO: replace this with something that can detect file read errors and actual 0-length files
|
||||
size_t flen = FileGetData(path, text, STD_BUFFER_SIZE - 1, 0);
|
||||
|
||||
text[flen] = '\0';
|
||||
u32 len = (ptrdiff_t)memchr(text, '\0', flen + 1) - (ptrdiff_t)text;
|
||||
|
||||
if (!(ValidateText(text, len))) {
|
||||
|
||||
if (!(ValidateText(text, flen))) {
|
||||
free(text);
|
||||
return luaL_error(L, "text validation failed");
|
||||
}
|
||||
|
||||
if (!(MemTextViewer(text, len, 1, false))) {
|
||||
if (!(MemTextViewer(text, flen, 1, false, STD_BUFFER_SIZE - 1, path))) {
|
||||
free(text);
|
||||
return luaL_error(L, "failed to run MemTextViewer");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user