From: Adam Dickmeiss Date: Wed, 24 Jan 1996 10:13:56 +0000 (+0000) Subject: Bug fix: in function wo_write realloc is used only when memory is already X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=73041203f9c387b4596185203b1daebe2f4f30e9;p=egate.git Bug fix: in function wo_write realloc is used only when memory is already allocated with malloc. --- diff --git a/www/Makefile b/www/Makefile index 568be3c..f737871 100644 --- a/www/Makefile +++ b/www/Makefile @@ -1,14 +1,14 @@ # Makefile for www gateway utility # Europagate, 1995 # -# $Id: Makefile,v 1.23 1996/01/09 17:14:34 adam Exp $ +# $Id: Makefile,v 1.24 1996/01/24 10:13:56 adam Exp $ # SHELL=/bin/sh # ZDEFS= ZINC=-I../../yaz/include ZLIB=../../yaz/lib/libyaz.a -MOSILIB=../../xtimosi/src/libmosi.a -lrfc +#MOSILIB=../../xtimosi/src/libmosi.a -lrfc LIBIRTCL=../../ir-tcl/libirtcl.a $(ZLIB) $(MOSILIB) #NETLIB=-lnsl -lsocket # @@ -49,14 +49,14 @@ DEFS=$(INCLUDE) $(ZDEFS) -DCGIDIR=\"$(CGIDIR)\" -DEGWDIR=\"$(EGWDIR)\" \ all: $(TPROG1) $(TPROG2) $(TPROG1): $(P1) - $(CC) $(CFLAGS) -o $(TPROG1) $(P1) $(OLIB) + $(CC) $(CFLAGS) -o $(TPROG1) $(P1) $(OLIB) $(ZLIB) $(TPROG2): $(P2) $(CC) $(CFLAGS) -o $(TPROG2) $(P2) $(OLIB) $(LIBIRTCL) \ $(NETLIB) $(TCLLIB) -lm $(TPROG3): $(P3) - $(CC) $(CFLAGS) -o $(TPROG3) $(P3) $(OLIB) + $(CC) $(CFLAGS) -o $(TPROG3) $(P3) $(OLIB) $(ZLIB) install: install.prog install.script diff --git a/www/wproto.c b/www/wproto.c index 35479b3..a90223e 100644 --- a/www/wproto.c +++ b/www/wproto.c @@ -41,7 +41,11 @@ * USE OR PERFORMANCE OF THIS SOFTWARE. * * $Log: wproto.c,v $ - * Revision 1.15 1996/01/24 08:25:32 adam + * Revision 1.16 1996/01/24 10:13:56 adam + * Bug fix: in function wo_write realloc is used only when memory is already + * allocated with malloc. + * + * Revision 1.15 1996/01/24 08:25:32 adam * Buf fix: Uninitialized outbuffer_offset member. * * Revision 1.14 1996/01/12 13:08:07 adam @@ -126,8 +130,14 @@ static char *mod = "wproto"; void wo_write (WCLIENT wc, const char *s, size_t len) { if (wc->outbuffer_offset + len >= wc->outbuffer_size) - wc->outbuffer = realloc(wc->outbuffer, wc->outbuffer_size += - ((len >= OUTBUFFER_CHUNK) ? len*2 : OUTBUFFER_CHUNK)); + { + if (!wc->outbuffer) + wc->outbuffer = malloc (wc->outbuffer_size += + ((len >= OUTBUFFER_CHUNK) ? len*2 : OUTBUFFER_CHUNK)); + else + wc->outbuffer = realloc(wc->outbuffer, wc->outbuffer_size += + ((len >= OUTBUFFER_CHUNK) ? len*2 : OUTBUFFER_CHUNK)); + } memcpy(wc->outbuffer + wc->outbuffer_offset, s, len); wc->outbuffer_offset += len; }