File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -227,21 +227,27 @@ static int ui_show_file_text_viewer(lua_State* L) {
227
227
// and FileTextViewer calls the above function
228
228
229
229
char * text = malloc (STD_BUFFER_SIZE );
230
- if (!text ) return false;
230
+ if (!text ) {
231
+ return luaL_error (L , "could not allocate memory" );
232
+ };
231
233
232
234
u32 flen = FileGetData (path , text , STD_BUFFER_SIZE - 1 , 0 );
233
235
234
236
text [flen ] = '\0' ;
235
237
u32 len = (ptrdiff_t )memchr (text , '\0' , flen + 1 ) - (ptrdiff_t )text ;
236
238
237
239
if (!(ValidateText (text , len ))) {
240
+ free (text );
238
241
return luaL_error (L , "text validation failed" );
239
242
}
240
243
241
244
if (!(MemTextViewer (text , len , 1 , false))) {
245
+ free (text );
242
246
return luaL_error (L , "failed to run MemTextViewer" );
243
247
}
244
248
249
+ free (text );
250
+
245
251
return 0 ;
246
252
}
247
253
You can’t perform that action at this time.
0 commit comments