create_input_stream: 在 malloc 失败时泄露 JNI 全局引用

作者: QiuYucheng2003创建于 2026年9月21日更新于 2026年9月21日

In create_input_stream in app/src/main/cpp/jni/stream/input_stream.c, the buffer is first promoted to a JNI global reference, and then malloc is used to allocate an InputStream. When malloc fails, it returns NULL directly, without calling DeleteGlobalRef. The JNI global reference is not automatically released when the native function returns. In destroy_input_stream, although the is and buffer are deleted, they depend on the already allocated structure, so this failure path cannot be taken, and the buffer will remain in the global reference table.

内容来源: xiaojieonly/Ehviewer_CN_SXJ