diff options
| author | Po Lu | 2024-07-07 10:19:31 +0800 |
|---|---|---|
| committer | Po Lu | 2024-07-07 10:21:47 +0800 |
| commit | 99e510977b22ca60e48b2af70a3c2cdbd90b2b01 (patch) | |
| tree | 272cbf70afee36d54807768fcac0df40ede58a43 /src/androidvfs.c | |
| parent | bbe95a8ceabfa1f4ad2064e1607fe64cf56434fd (diff) | |
| download | emacs-99e510977b22ca60e48b2af70a3c2cdbd90b2b01.tar.gz emacs-99e510977b22ca60e48b2af70a3c2cdbd90b2b01.zip | |
Correct JNI string error checking and miscellaneous corrections
* src/android-emacs.c (main): Do not attempt to load the
bootstrap class path, which is redundant on all Android releases.
* src/android.c (initEmacs, android_browse_url): Do not assume
exceptions will be raised if GetStringUTFChars fails. Decode
Android JNI strings as Qandroid_jni.
* src/androidvfs.c (android_saf_check_nonnull): New function.
(android_saf_new_mkdir): Likewise.
Diffstat (limited to 'src/androidvfs.c')
| -rw-r--r-- | src/androidvfs.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/androidvfs.c b/src/androidvfs.c index 346eb639b11..2427708be34 100644 --- a/src/androidvfs.c +++ b/src/androidvfs.c | |||
| @@ -3162,6 +3162,37 @@ android_saf_exception_check (int n, ...) | |||
| 3162 | return 1; | 3162 | return 1; |
| 3163 | } | 3163 | } |
| 3164 | 3164 | ||
| 3165 | /* Verify that OBJECT is non-NULL. If NULL, free each of the N local | ||
| 3166 | references given as arguments, and clear exceptions. | ||
| 3167 | |||
| 3168 | Value is 1 if it be NULL, 0 otherwise. */ | ||
| 3169 | |||
| 3170 | static int | ||
| 3171 | android_saf_check_nonnull (jobject object, int n, ...) | ||
| 3172 | { | ||
| 3173 | va_list ap; | ||
| 3174 | |||
| 3175 | if (object) | ||
| 3176 | return 0; | ||
| 3177 | |||
| 3178 | va_start (ap, n); | ||
| 3179 | |||
| 3180 | /* Clear the active exception, making it safe to subsequently call | ||
| 3181 | other JNI functions. */ | ||
| 3182 | (*android_java_env)->ExceptionClear (android_java_env); | ||
| 3183 | |||
| 3184 | /* Delete each of the N arguments. */ | ||
| 3185 | |||
| 3186 | while (n > 0) | ||
| 3187 | { | ||
| 3188 | ANDROID_DELETE_LOCAL_REF (va_arg (ap, jobject)); | ||
| 3189 | n--; | ||
| 3190 | } | ||
| 3191 | |||
| 3192 | va_end (ap); | ||
| 3193 | return 1; | ||
| 3194 | } | ||
| 3195 | |||
| 3165 | 3196 | ||
| 3166 | 3197 | ||
| 3167 | /* Content authority-based vnode implementation. | 3198 | /* Content authority-based vnode implementation. |
| @@ -6428,7 +6459,7 @@ android_saf_new_mkdir (struct android_vnode *vnode, mode_t mode) | |||
| 6428 | new_doc_id = (*android_java_env)->GetStringUTFChars (android_java_env, | 6459 | new_doc_id = (*android_java_env)->GetStringUTFChars (android_java_env, |
| 6429 | new_id, NULL); | 6460 | new_id, NULL); |
| 6430 | 6461 | ||
| 6431 | if (android_saf_exception_check (3, name, id, uri)) | 6462 | if (android_saf_check_nonnull (new_doc_id, 3, name, id, uri)) |
| 6432 | return -1; | 6463 | return -1; |
| 6433 | 6464 | ||
| 6434 | xfree (vp->document_id); | 6465 | xfree (vp->document_id); |