@@ -56,7 +56,12 @@ bool retro_vfs_init_saf(JNIEnv *(*get_jni_env)(void), jobject activity_object)
5656 return false;
5757
5858 (* env )-> PushLocalFrame (env , 14 );
59- if ((* env )-> ExceptionOccurred (env )) goto error ;
59+ if ((* env )-> ExceptionOccurred (env ))
60+ {
61+ (* env )-> ExceptionDescribe (env );
62+ (* env )-> ExceptionClear (env );
63+ return false;
64+ }
6065
6166 vfs_saf_content_resolver_object = NULL ;
6267 vfs_saf_vfs_implementation_saf_class = NULL ;
@@ -382,7 +387,12 @@ int retro_vfs_file_open_saf(const char *tree, const char *path, unsigned mode)
382387 return -1 ;
383388
384389 (* env )-> PushLocalFrame (env , 2 );
385- if ((* env )-> ExceptionOccurred (env )) goto error ;
390+ if ((* env )-> ExceptionOccurred (env ))
391+ {
392+ (* env )-> ExceptionDescribe (env );
393+ (* env )-> ExceptionClear (env );
394+ return -1 ;
395+ }
386396
387397 tree_object = (* env )-> NewStringUTF (env , tree );
388398 if ((* env )-> ExceptionOccurred (env )) goto error ;
@@ -417,7 +427,12 @@ int retro_vfs_file_remove_saf(const char *tree, const char *path)
417427 return -1 ;
418428
419429 (* env )-> PushLocalFrame (env , 2 );
420- if ((* env )-> ExceptionOccurred (env )) goto error ;
430+ if ((* env )-> ExceptionOccurred (env ))
431+ {
432+ (* env )-> ExceptionDescribe (env );
433+ (* env )-> ExceptionClear (env );
434+ return -1 ;
435+ }
421436
422437 tree_object = (* env )-> NewStringUTF (env , tree );
423438 if ((* env )-> ExceptionOccurred (env )) goto error ;
@@ -459,7 +474,12 @@ int retro_vfs_stat_saf(const char *tree, const char *path, int32_t *size)
459474 return 0 ;
460475
461476 (* env )-> PushLocalFrame (env , 3 );
462- if ((* env )-> ExceptionOccurred (env )) goto error ;
477+ if ((* env )-> ExceptionOccurred (env ))
478+ {
479+ (* env )-> ExceptionDescribe (env );
480+ (* env )-> ExceptionClear (env );
481+ return 0 ;
482+ }
463483
464484 tree_object = (* env )-> NewStringUTF (env , tree );
465485 if ((* env )-> ExceptionOccurred (env )) goto error ;
@@ -521,7 +541,12 @@ int retro_vfs_mkdir_saf(const char *tree, const char *dir)
521541 return -1 ;
522542
523543 (* env )-> PushLocalFrame (env , 2 );
524- if ((* env )-> ExceptionOccurred (env )) goto error ;
544+ if ((* env )-> ExceptionOccurred (env ))
545+ {
546+ (* env )-> ExceptionDescribe (env );
547+ (* env )-> ExceptionClear (env );
548+ return -1 ;
549+ }
525550
526551 tree_object = (* env )-> NewStringUTF (env , tree );
527552 if ((* env )-> ExceptionOccurred (env )) goto error ;
@@ -560,7 +585,13 @@ libretro_vfs_implementation_saf_dir *retro_vfs_opendir_saf(const char *tree, con
560585 return NULL ;
561586
562587 (* env )-> PushLocalFrame (env , 2 );
563- if ((* env )-> ExceptionOccurred (env )) goto error ;
588+ if ((* env )-> ExceptionOccurred (env ))
589+ {
590+ free (dirstream );
591+ (* env )-> ExceptionDescribe (env );
592+ (* env )-> ExceptionClear (env );
593+ return NULL ;
594+ }
564595
565596 tree_object = (* env )-> NewStringUTF (env , tree );
566597 if ((* env )-> ExceptionOccurred (env )) goto error ;
@@ -602,7 +633,12 @@ bool retro_vfs_readdir_saf(libretro_vfs_implementation_saf_dir *dirstream)
602633 return false;
603634
604635 (* env )-> PushLocalFrame (env , 1 );
605- if ((* env )-> ExceptionOccurred (env )) goto error ;
636+ if ((* env )-> ExceptionOccurred (env ))
637+ {
638+ (* env )-> ExceptionDescribe (env );
639+ (* env )-> ExceptionClear (env );
640+ return false;
641+ }
606642
607643 ret = (* env )-> CallBooleanMethod (env , dirstream -> directory_object , vfs_saf_saf_directory_readdir_method );
608644 if ((* env )-> ExceptionOccurred (env )) goto error ;
0 commit comments