Received: (at submit) by bugs.debian.org; 12 Oct 1999 13:06:51 +0000 Received: (qmail 17380 invoked from network); 12 Oct 1999 13:06:47 -0000 Received: from azure.humbug.org.au (mail@203.24.22.40) by master.debian.org with SMTP; 12 Oct 1999 13:06:47 -0000 Received: from aj by azure.humbug.org.au with local (Exim 3.03 #1 (Debian)) id 11b1aK-0002t4-00; Tue, 12 Oct 1999 23:03:20 +1000 From: Subject: dpkg: Memleak in libdpkg when using parseversion() (lib/parsehelp.c) To: submit@bugs.debian.org X-Mailer: bug 3.2.2 Message-Id: Date: Tue, 12 Oct 1999 23:03:20 +1000 Package: dpkg Version: 1.4.1.13 Severity: wishlist parseversion calls nfstrsave which is a strdup() clone which calls nfmalloc(), dpkg's non-freeing malloc. When using a cmpversions() based on dpkg's (see main/enquire.c) in a long lived process that does a lot of comparisons, all this memory is completely wasted. The program I'm working loses a good 3MB every 5s or so thanks to this. (What can I say? I do a lot of version comparisons) A workaround is to use libapt-pkg's version comparison stuff instead, which doesn't leak memory in any noticable amount. Something like: #include extern "C" { int cmpversions(char *left, char *op, char *right) { int i = pkgVersionCompare(left, right); if (!strcmp(op, "<=")) return i <= 0; if (!strcmp(op, ">=")) return i >= 0; if (!strcmp(op, "<<")) return i < 0; if (!strcmp(op, ">>")) return i > 0; if (!strcmp(op, "=")) return i == 0; } } in a C++ source file gives similar behaviour to the original (although it returns 1/0 for true/false (C-style) instead of 0/1 (shell style), and doesn't handle as many operators, or error conditions). Cheers, aj -- System Information Debian Release: potato Kernel Version: Linux azure 2.0.33 #1 Fri May 15 19:45:40 EST 1998 i586 unknown Versions of the packages dpkg depends on: ii libc6 2.1.2-0pre12 GNU C Library: Shared libraries and timezone ii libncurses4 4.2-3.2 Shared libraries for terminal handling ii libstdc++2.10 2.95.1-1 The GNU stdc++ library