]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
readline/
authorJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 29 Jun 2011 21:46:43 +0000 (21:46 +0000)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Wed, 29 Jun 2011 21:46:43 +0000 (21:46 +0000)
Avoid free from a signal handler.
* Makefile.in (xmalloc.o): Add readline.h.
* xmalloc.c: Include readline.h.
(xmalloc, xrealloc): Disable them by #if 0.
(xfree): Return on RL_STATE_SIGHANDLER, #undef free.
* xmalloc.h (xfree, free): New definition.

readline/ChangeLog.gdb
readline/Makefile.in
readline/xmalloc.c
readline/xmalloc.h

index 4a09ea5fc401cca46a86bb5ab27a05d88931fba6..476292511753028ad6ca0e18151c0d57abc55318 100644 (file)
@@ -1,3 +1,12 @@
+2011-06-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       Avoid free from a signal handler.
+       * Makefile.in (xmalloc.o): Add readline.h.
+       * xmalloc.c: Include readline.h.
+       (xmalloc, xrealloc): Disable them by #if 0.
+       (xfree): Return on RL_STATE_SIGHANDLER, #undef free.
+       * xmalloc.h (xfree, free): New definition.
+
 2011-03-04  Michael Snyder  <msnyder@vmware.com>
 
        * bind.c (rl_function_dumper): Free allocated memory.
index 4423b237b48964a224f0cbd2afb34e882eaf0fb3..0f5607b77ad89ee1dc3e20269b82e9de5b0087cc 100644 (file)
@@ -417,7 +417,7 @@ vi_mode.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
 vi_mode.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
 vi_mode.o: history.h ansi_stdlib.h rlstdc.h
 xmalloc.o: ${BUILD_DIR}/config.h
-xmalloc.o: ansi_stdlib.h
+xmalloc.o: ansi_stdlib.h readline.h
 
 bind.o: rlshell.h
 histfile.o: rlshell.h
index 8985d340d398cd28f5278c8c275cad0faed4a592..2087d3df63b3ea3e31550b508bc4f7816edf99e6 100644 (file)
@@ -33,6 +33,7 @@
 #endif /* HAVE_STDLIB_H */
 
 #include "xmalloc.h"
+#include "readline.h"
 
 /* **************************************************************** */
 /*                                                                 */
@@ -40,6 +41,9 @@
 /*                                                                 */
 /* **************************************************************** */
 
+/* xmalloc and xrealloc are provided by GDB.  */
+#if 0
+
 static void
 memory_error_and_abort (fname)
      char *fname;
@@ -77,12 +81,20 @@ xrealloc (pointer, bytes)
   return (temp);
 }
 
+/* xmalloc and xrealloc are provided by GDB.  */
+#endif /* 0 */
+
 /* Use this as the function to call when adding unwind protects so we
    don't need to know what free() returns. */
 void
 xfree (string)
      PTR_T string;
 {
+  /* Leak a bit.  */
+  if (RL_ISSTATE(RL_STATE_SIGHANDLER))
+    return;
+
+#undef free
   if (string)
     free (string);
 }
index 9cb08ba21f111caabc5849683438eb529ad14ef3..1703920874ebcc0cb032daf9fe68bfb03a377b82 100644 (file)
 
 #endif /* !PTR_T */
 
+/* xmalloc and xrealloc should be also protected from RL_STATE_SIGHANDLER.  */
+#define xfree xfree_readline
+
+/* readline-5.1 backport.  */
+#define free xfree
+
 extern PTR_T xmalloc PARAMS((size_t));
 extern PTR_T xrealloc PARAMS((void *, size_t));
 extern void xfree PARAMS((void *));