From 8b9d25b4087df936d51aacd137affbce6469d717 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 9 Sep 2023 15:49:47 +0800 Subject: [PATCH] Update Android port * src/android-asset.h (android_asset_read_internal): Return an error indication if an exception arises while reading. (AAsset_getBuffer): Free BUFFER using the C library free function. --- src/android-asset.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/android-asset.h b/src/android-asset.h index 4fb309f1645..d7cf0f0cfed 100644 --- a/src/android-asset.h +++ b/src/android-asset.h @@ -340,7 +340,7 @@ android_asset_read_internal (AAsset *asset, int nbytes, char *buffer) /* Detect error conditions. */ if ((*env)->ExceptionCheck (env)) - goto out; + goto out_errno; /* Detect EOF. */ @@ -363,6 +363,14 @@ android_asset_read_internal (AAsset *asset, int nbytes, char *buffer) (*env)->ExceptionClear (env); (*env)->DeleteLocalRef (env, stash); return total; + + out_errno: + /* Return an error indication if an exception arises while the file + is being read. */ + (*env)->ExceptionClear (env); + (*env)->DeleteLocalRef (env, stash); + errno = EIO; + return -1; } static long @@ -399,7 +407,7 @@ AAsset_getBuffer (AAsset *asset) if (android_asset_read_internal (asset, length, buffer) != length) { - xfree (buffer); + free (buffer); return NULL; } -- 2.39.5