File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -425,21 +425,29 @@ static int RE_LoadFontFile( const char *name, void **buffer )
425425 return sizeof ( daemon_unifont_bin );
426426 }
427427
428- void *tmp;
429- int length = ri.FS_ReadFile ( name, &tmp );
428+ std::string tmp;
430429
431- if ( length <= 0 )
430+ try
431+ {
432+ tmp = FS::HomePath::OpenRead ( name ).ReadAll ();
433+ }
434+ catch ( const std::system_error &exc )
435+ {
436+ Log::Warn ( " Failed to read font file: %s" , exc.what () );
437+ return 0 ;
438+ }
439+
440+ if ( tmp.size () > 1000 * 1000 * 1000 )
432441 {
433442 return 0 ;
434443 }
435444
436- void *data = Z_AllocUninit ( length );
445+ void *data = Z_AllocUninit ( tmp. size () );
437446 *buffer = data;
438447
439- memcpy ( data, tmp, length );
440- ri.FS_FreeFile ( tmp );
448+ memcpy ( data, tmp.data (), tmp.size () );
441449
442- return length ;
450+ return tmp. size () ;
443451}
444452
445453static void RE_FreeFontFile ( void *data )
You can’t perform that action at this time.
0 commit comments