Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] queue signals while calling malloc() in the implementation of realloc()



... also in the special case of realloc(NULL, size) where size > 0

Bug: https://bugzilla.redhat.com/1267903#c6
---
 Src/mem.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Src/mem.c b/Src/mem.c
index 68bd767..9055d0a 100644
--- a/Src/mem.c
+++ b/Src/mem.c
@@ -1650,18 +1650,23 @@ zsfree(char *p)
 MALLOC_RET_T
 realloc(MALLOC_RET_T p, MALLOC_ARG_T size)
 {
     struct m_hdr *m = (struct m_hdr *)(((char *)p) - M_ISIZE), *mt;
     char *r;
     int i, l = 0;
 
     /* some system..., see above */
-    if (!p && size)
-	return (MALLOC_RET_T) malloc(size);
+    if (!p && size) {
+	queue_signals();
+	r = malloc(size);
+	unqueue_signals();
+	return (MALLOC_RET_T) r;
+    }
+
     /* and some systems even do this... */
     if (!p || !size)
 	return (MALLOC_RET_T) p;
 
     queue_signals();  /* just queue signals caught rather than handling them */
 
     /* check if we are reallocating a small block, if we do, we have
        to compute the size of the block from the sort of block it is in */
-- 
2.5.2



Messages sorted by: Reverse Date, Date, Thread, Author