Bug#611232: libx11-6: XrmSetDatabase is documented to not free the database, but frees it, causing crashes
Package: libx11-6
Version: 2:1.3.3-4
Severity: normal
The documentation for XrmSetDatabase says:
"The database previously associated with the display (if any) is not
destroyed."
Consequently, to avoid memory leaks, rxvt-unicode uses this to replace it:
XrmDestroyDatabase (XrmGetDatabase (dpy));
XrmSetDatabase (dpy, get_resources (true));
This works almost always. However, sometimes, some third-party library
calls XGetDefault itself, and this causes the undocumented behaviour of
freeing the resource database in XrmSetDatabase.
LockDisplay(display);
/* destroy database if set up imlicitely by XGetDefault() */
if (display->db && (display->flags & XlibDisplayDfltRMDB)) {
XrmDestroyDatabase(display->db);
display->flags &= ~XlibDisplayDfltRMDB;
}
display->db = database;
UnlockDisplay(display);
This makes it basically impossible to both avoid a memory leak AND not
crashing on a double free.
And either the manpage is wrong (which claims the database isn't freed) or
the code.
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.37-trunk-amd64 (SMP w/4 CPU cores)
Locale: LANG=C, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages libx11-6 depends on:
hi libc6 2.11.2-7 Embedded GNU C Library: Shared lib
ii libx11-data 2:1.3.3-4 X11 client-side library
ii libxcb1 1.6-1 X C Binding
libx11-6 recommends no packages.
libx11-6 suggests no packages.
-- debconf information excluded
Reply to: