java - Memory leak in JNI function Java_java_io_WinNTFileSystem_rename0? -
i think following function in file jdk/src/windows/native/java/io/winntfilesystem_md.c in http://download.java.net/openjdk/jdk6/promoted/b27/openjdk-6-src-b27-26_oct_2012.tar.gz neglects free memory used frompath
or topath
if 1 of them found null
...
jniexport jboolean jnicall java_java_io_winntfilesystem_rename0(jnienv *env, jobject this, jobject from, jobject to) { jboolean rv = jni_false; wchar *frompath = filetontpath(env, from, ids.path); wchar *topath = filetontpath(env, to, ids.path); if (frompath == null || topath == null) return jni_false; if (_wrename(frompath, topath) == 0) { rv = jni_true; } free(frompath); free(topath); return rv; }
am missing something? in fact bug?
resolved: looking further details of function pathtontpath
in io_util_md.c, can see filetontpath
return null
in case of out-of-memory error, guess don't care if neglect free malloc
ed when jvm crash! still should documented in java_java_io_winntfilesystem_rename0
function in opinion though.
i think original point valid. while research other function used code suggest problem might not important, code lacking when viewed in , of itself.
the general rule of code reviews if has question, should answered in code @ least comment.
the general rule of comments if can expressed in code, possibly should be.
all of these issues go away if code written eliminate question.
Comments
Post a Comment