]> git.eshelyaron.com Git - emacs.git/commitdiff
Update Android port
authorPo Lu <luangruo@yahoo.com>
Sat, 9 Sep 2023 07:49:47 +0000 (15:49 +0800)
committerPo Lu <luangruo@yahoo.com>
Sat, 9 Sep 2023 07:50:06 +0000 (15:50 +0800)
* 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

index 4fb309f1645778a38ff62439d7ffd38806df408f..d7cf0f0cfed358a59db2963e93f1a1b053f73a18 100644 (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;
     }