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.
This commit is contained in:
Po Lu 2023-09-09 15:49:47 +08:00
parent 09840a8a2f
commit 8b9d25b408

View file

@ -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;
}