Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d657a38d authored by George Burgess IV's avatar George Burgess IV
Browse files

Fix static analyzer complaints

frameworks/base/core/jni/android_view_MotionEvent.cpp:383:12: warning:
Potential leak of memory pointed to by 'event'

frameworks/base/core/jni/AndroidRuntime.cpp:975:20: warning: Null passed
to a callee that requires a non-null 1st parameter

For the former, it was surprising to me that the analyzer couldn't
figure out that `event == nativePtr` for the latter check. Filed
https://bugs.llvm.org/show_bug.cgi?id=33540 upstream about it.

For the latter, it was complaining because `className` could be NULL
(more precisely, we have a NULL check at the top of the function it's
declared in, so NULL is presumably a valid value).

Bug: None
Test: Ran mma; complaints are gone.
Change-Id: I26a91ae25934f95acbfdbe4f3641e081fbc66c6d
parent d1ffb134
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1094,7 +1094,7 @@ void AndroidRuntime::start(const char* className, const Vector<String8>& options
     * Start VM.  This thread becomes the main thread of the VM, and will
     * not return until the VM exits.
     */
    char* slashClassName = toSlashClassName(className);
    char* slashClassName = toSlashClassName(className != NULL ? className : "");
    jclass startClass = env->FindClass(slashClassName);
    if (startClass == NULL) {
        ALOGE("JavaVM unable to locate class '%s'\n", slashClassName);
+4 −2
Original line number Diff line number Diff line
@@ -345,8 +345,10 @@ static jlong android_view_MotionEvent_nativeInitialize(JNIEnv* env, jclass clazz
        return 0;
    }

    MotionEvent* event = reinterpret_cast<MotionEvent*>(nativePtr);
    if (!event) {
    MotionEvent* event;
    if (nativePtr) {
        event = reinterpret_cast<MotionEvent*>(nativePtr);
    } else {
        event = new MotionEvent();
    }