From: Fabian Keil <fk@fabiankeil.de>
Date: Sun, 13 Jun 2010 12:25:33 +0000 (+0000)
Subject: In add_to_iob(), limit the scope of the variable 'want' and turn an interestingly... 
X-Git-Tag: v_3_0_17~139
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/developer-manual/man-page/faq/@default-cgi@?a=commitdiff_plain;h=f4d4d38402b997bd687ab86577b533c523baecc6;p=privoxy.git

In add_to_iob(), limit the scope of the variable 'want' and turn an interestingly looking for loop into a boring while loop.
---

diff --git a/parsers.c b/parsers.c
index c24b518a..2f6f7653 100644
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.210 2009/12/25 11:39:26 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.211 2010/05/01 18:20:50 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -318,7 +318,7 @@ long flush_socket(jb_socket fd, struct iob *iob)
 jb_err add_to_iob(struct client_state *csp, char *buf, long n)
 {
    struct iob *iob = csp->iob;
-   size_t used, offset, need, want;
+   size_t used, offset, need;
    char *p;
 
    if (n <= 0) return JB_ERR_OK;
@@ -341,7 +341,12 @@ jb_err add_to_iob(struct client_state *csp, char *buf, long n)
 
    if (need > iob->size)
    {
-      for (want = csp->iob->size ? csp->iob->size : 512; want <= need;) want *= 2;
+      size_t want = csp->iob->size ? csp->iob->size : 512;
+
+      while (want <= need)
+      {
+         want *= 2;
+      }
       
       if (want <= csp->config->buffer_limit && NULL != (p = (char *)realloc(iob->buf, want)))
       {