Repository: libsdl-org/SDL
File: src/core/android/SDL_android.c (C)

Code before:
                size_t cpy = SDL_strlcpy(ptr, argv0, remain) + 1;
                argv[argc++] = ptr;
                SDL_assert(cpy <= remain); remain -= cpy; ptr += cpy;
                for (int i = 0; i < len; ++i) {
                    jstring string = (*env)->GetObjectArrayElement(env, array, i);
                    const char *utf = string ? (*env)->GetStringUTFChars(env, string, 0) : NULL;
                    cpy = SDL_strlcpy(ptr, utf ? utf : "", remain) + 1;
                    if (cpy < remain) {
                        argv[argc++] = ptr;
                        remain -= cpy;
                        ptr += cpy;
                    }
                    if (utf) {
                        (*env)->ReleaseStringUTFChars(env, string, utf);
                    }
                    if (string) {
                        (*env)->DeleteLocalRef(env, string);
                    }
                }
                argv[argc] = NULL;

                // Run the application.
                status = SDL_RunApp(argc, argv, SDL_main, NULL);

                // Release the arguments.
                free(args);  // free, not SDL_free!
            }
        } else {
            __android_log_print(ANDROID_LOG_ERROR, "SDL", "nativeRunMain(): Couldn't find function %s in library %s", function_name, library_file);
        }
        (*env)->ReleaseStringUTFChars(env, function, function_name);

        dlclose(library_handle);

    } else {
        __android_log_print(ANDROID_LOG_ERROR, "SDL", "nativeRunMain(): Couldn't load library %s", library_file);
    }
    (*env)->ReleaseStringUTFChars(env, library, library_file);

    // Do not issue an exit or the whole application will terminate instead of just the SDL thread
    // exit(status);

    return status;
}

static int FindLifecycleEvent(SDL_AndroidLifecycleEvent event)
{
    for (int index = 0; index < Android_NumLifecycleEvents; ++index) {
        if (Android_LifecycleEvents[index] == event) {
            return index;
        }

Review comment (suggestion):
`build-scripts/check_stdlib_usage.py` is very strict:
https://github.com/libsdl-org/SDL/blob/4e79d2ad64576e9ec650635609d217ab25a89b11/build-scripts/check_stdlib_usage.py#L223-L229
```suggestion
                free(args);  // This should NOT be SDL_free()
```

Code after:
                size_t cpy = SDL_strlcpy(ptr, argv0, remain) + 1;
                argv[argc++] = ptr;
                SDL_assert(cpy <= remain); remain -= cpy; ptr += cpy;
                for (int i = 0; i < len; ++i) {
                    jstring string = (*env)->GetObjectArrayElement(env, array, i);
                    const char *utf = string ? (*env)->GetStringUTFChars(env, string, 0) : NULL;
                    cpy = SDL_strlcpy(ptr, utf ? utf : "", remain) + 1;
                    if (cpy < remain) {
                        argv[argc++] = ptr;
                        remain -= cpy;
                        ptr += cpy;
                    }
                    if (utf) {
                        (*env)->ReleaseStringUTFChars(env, string, utf);
                    }
                    if (string) {
                        (*env)->DeleteLocalRef(env, string);
                    }
                }
                argv[argc] = NULL;

                // Run the application.
                status = SDL_RunApp(argc, argv, SDL_main, NULL);

                // Release the arguments.
                free(args);  // This should NOT be SDL_free()
            }
        } else {
            __android_log_print(ANDROID_LOG_ERROR, "SDL", "nativeRunMain(): Couldn't find function %s in library %s", function_name, library_file);
        }
        (*env)->ReleaseStringUTFChars(env, function, function_name);

        dlclose(library_handle);

    } else {
        __android_log_print(ANDROID_LOG_ERROR, "SDL", "nativeRunMain(): Couldn't load library %s", library_file);
    }
    (*env)->ReleaseStringUTFChars(env, library, library_file);

    // Do not issue an exit or the whole application will terminate instead of just the SDL thread
    // exit(status);

    return status;
}

static int FindLifecycleEvent(SDL_AndroidLifecycleEvent event)
{
    for (int index = 0; index < Android_NumLifecycleEvents; ++index) {
        if (Android_LifecycleEvents[index] == event) {
            return index;
        }