]> source.dussan.org Git - rspamd.git/commitdiff
* Fix bug in url parser with freeing memory allocated by memory_pool allocator
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 4 Mar 2009 16:14:30 +0000 (19:14 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 4 Mar 2009 16:14:30 +0000 (19:14 +0300)
* Do not write to log if we don't do any read operation in dispatcher library

src/buffer.c
src/url.c

index 5864da382701e2b3d2ae6f6e698af634677f545a..fe5cf7a72ec77acdd0b2df982c1ceb1bcc346338 100644 (file)
@@ -176,12 +176,11 @@ read_buffers (int fd, rspamd_io_dispatcher_t *d, gboolean skip_read)
                        d->in_buf->pos += r;
                        d->in_buf->data->len += r;
                }
-       
+               msg_debug ("read_buffers: read %ld characters, policy is %s, watermark is: %ld", 
+                               (long int)r, d->policy == BUFFER_LINE ? "LINE" : "CHARACTER",
+                               (long int)d->nchars);
        }
        
-       msg_debug ("read_buffers: read %ld characters, policy is %s, watermark is: %ld", 
-                       (long int)r, d->policy == BUFFER_LINE ? "LINE" : "CHARACTER",
-                       (long int)d->nchars);
        saved_policy = d->policy;
        c = d->in_buf->data->begin;
        r = 0;
index 09be6f1129f74d8e36e2b894bc068e216c8fceb0..31851c3bba1fe7627d6ce259b81d6875d0bba802 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -446,7 +446,7 @@ char_needs_escaping (const char *p)
 */
 
 static char *
-reencode_escapes (const char *s, memory_pool_t *pool)
+reencode_escapes (char *s, memory_pool_t *pool)
 {
        const char *p1;
        char *newstr, *p2;
@@ -462,7 +462,7 @@ reencode_escapes (const char *s, memory_pool_t *pool)
 
        if (!encode_count) {
                /* The string is good as it is. */
-               return memory_pool_strdup (pool, s);
+               return s;
        }
 
        oldlen = p1 - s;
@@ -620,8 +620,8 @@ parse_uri(struct uri *uri, unsigned char *uristring, memory_pool_t *pool)
        /* Assume http as default protocol */
        if (!uri->protocollen || (uri->protocol = get_protocol (struri(uri), uri->protocollen)) == PROTOCOL_UNKNOWN) {
                p = g_strconcat ("http://", uri->string, NULL);
-               g_free (uri->string);
-               uri->string = p;
+               uri->string = memory_pool_strdup (pool, p);
+               g_free (p);
                uri->protocol = PROTOCOL_HTTP;
                prefix_end = struri (uri) + 7;
        }