]> andersk Git - gssapi-openssh.git/commitdiff
patch for 2nd revision of http://www.openssh.com/txt/buffer.adv
authorjbasney <jbasney>
Wed, 17 Sep 2003 15:18:56 +0000 (15:18 +0000)
committerjbasney <jbasney>
Wed, 17 Sep 2003 15:18:56 +0000 (15:18 +0000)
openssh/buffer.c
openssh/channels.c

index 9370998c97ce6de009f55f05055568d1add1db73..d50756bdbfbc6eb150b06770554235e7cccbe5b3 100644 (file)
@@ -23,8 +23,11 @@ RCSID("$OpenBSD: buffer.c,v 1.16 2002/06/26 08:54:18 markus Exp $");
 void
 buffer_init(Buffer *buffer)
 {
-       buffer->alloc = 4096;
-       buffer->buf = xmalloc(buffer->alloc);
+       const u_int len = 4096;
+
+       buffer->alloc = 0;
+       buffer->buf = xmalloc(len);
+       buffer->alloc = len;
        buffer->offset = 0;
        buffer->end = 0;
 }
@@ -34,8 +37,10 @@ buffer_init(Buffer *buffer)
 void
 buffer_free(Buffer *buffer)
 {
-       memset(buffer->buf, 0, buffer->alloc);
-       xfree(buffer->buf);
+       if (buffer->alloc > 0) {
+               memset(buffer->buf, 0, buffer->alloc);
+               xfree(buffer->buf);
+       }
 }
 
 /*
index 1937b02446b5a9357b6f92532a888794893ffec2..218744d1ab4caa1c5b3a9ea2616d94ec6b12662d 100644 (file)
@@ -229,12 +229,13 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
        if (found == -1) {
                /* There are no free slots.  Take last+1 slot and expand the array.  */
                found = channels_alloc;
-               channels_alloc += 10;
                if (channels_alloc > 10000)
                        fatal("channel_new: internal error: channels_alloc %d "
                            "too big.", channels_alloc);
+               channels = xrealloc(channels,
+                   (channels_alloc + 10) * sizeof(Channel *));
+               channels_alloc += 10;
                debug2("channel: expanding %d", channels_alloc);
-               channels = xrealloc(channels, channels_alloc * sizeof(Channel *));
                for (i = found; i < channels_alloc; i++)
                        channels[i] = NULL;
        }
This page took 0.044516 seconds and 5 git commands to generate.