Package: libunixsocket-java Version: 0.7.2-3 Severity: normal Tags: patch We find a memory leak in libmatthew-java version 0.7.2. Here is the patch:
--- unix-java.c-orig 2010-07-26 10:06:55.000000000 +0800 +++ unix-java.c 2010-07-26 10:07:22.000000000 +0800 @@ -277,10 +277,10 @@ if (s+l > sblen || j == IOV_MAX) { msg.msg_iovlen = j; rv = sendmsg(sock, &msg, 0); - j = 0; s = 0; for (int k = i-1, l = j-1; l >= 0; k--, l--) (*env)->ReleaseByteArrayElements(env, b[k], iov[l].iov_base, 0); + j = 0; if (-1 == rv) { handleerrno(env); return -1; } } iov[j].iov_base = (*env)->GetByteArrayElements(env, b[i], NULL); Problem code if (s+l > sblen || j == IOV_MAX) { msg.msg_iovlen = j; rv = sendmsg(sock, &msg, 0); j = 0; //reset j (wrong place) s = 0; for (int k = i-1, l = j-1; l >= 0; k--, l--) //PROBLEM!! (*env)->ReleaseByteArrayElements(env, b[k], iov[l].iov_base, 0); if (-1 == rv) { handleerrno(env); return -1; } } iov[j].iov_base = (*env)->GetByteArrayElements(env, b[i], NULL); j is 0 and l be initialized as j - 1. It means that l will be -1 and the condition (l >= 0) will never meet. Therefore most of the memories allocated by GetByteArrayElements() would not be freed. j should be reset after loop. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org