From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1859 invoked by alias); 21 Oct 2015 09:08:32 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36906 Received: (qmail 17866 invoked from network); 21 Oct 2015 09:08:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 From: Kamil Dudka To: zsh-workers@zsh.org Subject: [PATCH] queue signals while calling malloc() in the implementation of realloc() Date: Wed, 21 Oct 2015 11:01:38 +0200 Message-Id: <1445418098-24475-1-git-send-email-kdudka@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 ... 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