* [PATCH] --enable-checking=xmallocoverrun
@ 2011-10-13 12:59 Dmitry Antipov
2011-10-13 14:57 ` Paul Eggert
0 siblings, 1 reply; 2+ messages in thread
From: Dmitry Antipov @ 2011-10-13 12:59 UTC (permalink / raw)
To: emacs-devel
[-- Attachment #1: Type: text/plain, Size: 410 bytes --]
When xmallocoverrun check is enabled, everything allocated with xmalloc() should be
passed to xfree(), not free(). Otherwise glibc will detect an inconsistency in the
internal malloc data structures and abort the program.
Due to this, Emacs configured with --enable-checking=xmallocoverrun currently crashes,
both with default (gtk) and lucid toolkits. Here is an obvious fix for all of these issues.
Dmitry
[-- Attachment #2: xfree.patch --]
[-- Type: text/plain, Size: 4954 bytes --]
=== modified file 'lwlib/ChangeLog'
--- lwlib/ChangeLog 2011-06-27 03:00:16 +0000
+++ lwlib/ChangeLog 2011-10-13 12:57:49 +0000
@@ -1,3 +1,13 @@
+2011-10-13 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * lwlib-Xaw.c (openFont, xaw_destroy_instance): Replace free with
+ xfree to avoid crash when xmalloc overrun checking is enabled.
+ * lwlib-Xm.c (free_destroyed_instance, xm_update_one_value): Ditto.
+ * lwlib-utils.c (XtApplyToWidgets): Ditto.
+ * lwlib.c (safe_free_str, free_widget_value, free_widget_value_tree)
+ (free_widget_info, free_widget_instance, name_to_widget): Ditto.
+ * xlwmenu.c (openXftFont): Ditto.
+
2011-06-27 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
* Makefile.in (ALL_CFLAGS): Add -I../lib for generated header files
=== modified file 'lwlib/lwlib-Xaw.c'
--- lwlib/lwlib-Xaw.c 2011-02-14 17:21:10 +0000
+++ lwlib/lwlib-Xaw.c 2011-10-13 12:47:26 +0000
@@ -136,7 +136,7 @@
}
fn = XftFontOpenName (XtDisplay (widget), screen, fname);
- if (fname != name) free (fname);
+ if (fname != name) xfree (fname);
return fn;
}
@@ -384,7 +384,7 @@
if (instance->xft_data[0].xft_font)
XftFontClose (XtDisplay (instance->widget),
instance->xft_data[0].xft_font);
- free (instance->xft_data);
+ xfree (instance->xft_data);
}
#endif
if (XtIsSubclass (instance->widget, dialogWidgetClass))
=== modified file 'lwlib/lwlib-Xm.c'
--- lwlib/lwlib-Xm.c 2011-04-16 21:22:40 +0000
+++ lwlib/lwlib-Xm.c 2011-10-13 12:47:26 +0000
@@ -186,9 +186,9 @@
static void
free_destroyed_instance (destroyed_instance* instance)
{
- free (instance->name);
- free (instance->type);
- free (instance);
+ xfree (instance->name);
+ xfree (instance->type);
+ xfree (instance);
}
\f/* motif utility functions */
@@ -928,13 +928,13 @@
}
else if (class == xmTextWidgetClass)
{
- free (val->value);
+ xfree (val->value);
val->value = XmTextGetString (widget);
val->edited = True;
}
else if (class == xmTextFieldWidgetClass)
{
- free (val->value);
+ xfree (val->value);
val->value = XmTextFieldGetString (widget);
val->edited = True;
}
@@ -959,7 +959,7 @@
XtVaGetValues (toggle, XmNset, &set, NULL);
if (set)
{
- free (val->value);
+ xfree (val->value);
val->value = safe_strdup (XtName (toggle));
}
}
=== modified file 'lwlib/lwlib-utils.c'
--- lwlib/lwlib-utils.c 2011-04-16 21:23:30 +0000
+++ lwlib/lwlib-utils.c 2011-10-13 12:47:26 +0000
@@ -80,7 +80,7 @@
XtApplyToWidgets (kids [i], proc, arg);
proc (kids [i], arg);
}
- free (kids);
+ xfree (kids);
}
}
=== modified file 'lwlib/lwlib.c'
--- lwlib/lwlib.c 2011-04-16 16:42:58 +0000
+++ lwlib/lwlib.c 2011-10-13 12:47:26 +0000
@@ -138,7 +138,7 @@
static void
safe_free_str (char *s)
{
- free (s);
+ xfree (s);
}
static widget_value *widget_value_free_list = 0;
@@ -176,7 +176,7 @@
{
/* When the number of already allocated cells is too big,
We free it. */
- free (wv);
+ xfree (wv);
malloc_cpt--;
}
else
@@ -192,9 +192,9 @@
if (!wv)
return;
- free (wv->name);
- free (wv->value);
- free (wv->key);
+ xfree (wv->name);
+ xfree (wv->value);
+ xfree (wv->key);
wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
@@ -281,7 +281,7 @@
safe_free_str (info->name);
free_widget_value_tree (info->val);
memset ((void*)info, 0xDEADBEEF, sizeof (widget_info));
- free (info);
+ xfree (info);
}
static void
@@ -317,7 +317,7 @@
free_widget_instance (widget_instance *instance)
{
memset ((void*)instance, 0xDEADBEEF, sizeof (widget_instance));
- free (instance);
+ xfree (instance);
}
static widget_info *
@@ -602,7 +602,7 @@
widget = XtNameToWidget (instance->widget, real_name);
- free (real_name);
+ xfree (real_name);
}
return widget;
}
=== modified file 'lwlib/xlwmenu.c'
--- lwlib/xlwmenu.c 2011-04-16 01:38:14 +0000
+++ lwlib/xlwmenu.c 2011-10-13 12:47:26 +0000
@@ -1891,7 +1891,7 @@
}
}
- if (fname != mw->menu.fontName) free (fname);
+ if (fname != mw->menu.fontName) xfree (fname);
return mw->menu.xft_font != 0;
}
=== modified file 'src/ChangeLog'
--- src/ChangeLog 2011-10-13 11:17:32 +0000
+++ src/ChangeLog 2011-10-13 12:57:27 +0000
@@ -1,3 +1,8 @@
+2011-10-13 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * editfns.c (Fset_time_zone_rule): Replace free with xfree to
+ avoid crash when xmalloc overrun checking is enabled.
+
2011-10-13 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (Fcurrent_bidi_paragraph_direction): Initialize
=== modified file 'src/editfns.c'
--- src/editfns.c 2011-09-15 18:11:37 +0000
+++ src/editfns.c 2011-10-13 12:47:26 +0000
@@ -2079,7 +2079,7 @@
}
set_time_zone_rule (tzstring);
- free (environbuf);
+ xfree (environbuf);
environbuf = environ;
return Qnil;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] --enable-checking=xmallocoverrun
2011-10-13 12:59 [PATCH] --enable-checking=xmallocoverrun Dmitry Antipov
@ 2011-10-13 14:57 ` Paul Eggert
0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2011-10-13 14:57 UTC (permalink / raw)
To: Dmitry Antipov; +Cc: emacs-devel
Thanks, I committed that fix in your name.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-13 14:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-13 12:59 [PATCH] --enable-checking=xmallocoverrun Dmitry Antipov
2011-10-13 14:57 ` Paul Eggert
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.