zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] queue signals while calling malloc() in the implementation of realloc()
@ 2015-10-21  9:01 Kamil Dudka
  2015-10-21 14:55 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Kamil Dudka @ 2015-10-21  9:01 UTC (permalink / raw)
  To: zsh-workers

... 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] queue signals while calling malloc() in the implementation of realloc()
  2015-10-21  9:01 [PATCH] queue signals while calling malloc() in the implementation of realloc() Kamil Dudka
@ 2015-10-21 14:55 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2015-10-21 14:55 UTC (permalink / raw)
  To: zsh-workers

On Oct 21, 11:01am, Kamil Dudka wrote:
} Subject: [PATCH] queue signals while calling malloc() in the implementatio
}
} ... also in the special case of realloc(NULL, size) where size > 0

This only applies if you used configure --enable-zsh-mem ...

There should also be queue_signals() in calloc() I suppose, but that's
never called by zsh itself.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-10-21 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-21  9:01 [PATCH] queue signals while calling malloc() in the implementation of realloc() Kamil Dudka
2015-10-21 14:55 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).