Don't print a log message every time filter_headers is
[privoxy.git] / debian / patches / 13_memory.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 13_memory.dpatch by David Schmidt <david__schmidt@users.sourceforge.net>
3 ##
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: A few memory leaks plugged (mostly on error paths)
6 ## DP: Removing a double free
7 ## DP: Don't forget to malloc space for the null terminator...
8
9 @DPATCH@
10 #diff -urNad privoxy~/cgisimple.c privoxy/cgisimple.c
11 #--- privoxy~/cgisimple.c       2006-02-11 18:55:17.000000000 +0100
12 #+++ privoxy/cgisimple.c        2006-02-11 18:55:27.000000000 +0100
13 #@@ -880,12 +880,13 @@
14 #             string_join  (&s, html_encode(buf));
15 #          }
16 #          fclose(fp);
17 #-
18 #          if (map(exports, "contents", 1, s, 0))
19 #          {
20 #+            freez(s);
21 #             free_map(exports);
22 #             return JB_ERR_MEMORY;
23 #          }
24 #+         freez(s);
25 #       }
26
27 #       return template_fill_for_cgi(csp, "show-status-file", exports, rsp);
28 #@@ -898,7 +899,7 @@
29 #       if (!err) err = string_append(&s, " ");
30 #    }
31 #    if (!err) err = map(exports, "invocation", 1, s, 0);
32 #-
33 #+   freez(s);
34 #    if (!err) err = map(exports, "options", 1, csp->config->proxy_args, 1);
35 #    if (!err) err = show_defines(exports);
36
37 diff -urNad privoxy~/filters.c privoxy/filters.c
38 --- privoxy~/filters.c  2006-02-11 18:55:17.000000000 +0100
39 +++ privoxy/filters.c   2006-02-11 18:55:27.000000000 +0100
40 @@ -966,6 +966,7 @@
41        string_append(&p, buf);
42     }
43     err = map(exports, "trusted-referrers", 1, p, 0);
44 +   freez(p);
45  
46     if (err)
47     {
48 @@ -988,6 +989,7 @@
49           string_append(&p, buf);
50        }
51        err = map(exports, "trust-info", 1, p, 0);
52 +      freez(p);
53     }
54     else
55     {
56 diff -urNad privoxy~/jbsockets.c privoxy/jbsockets.c
57 --- privoxy~/jbsockets.c        2004-01-31 10:27:50.000000000 +0100
58 +++ privoxy/jbsockets.c 2006-02-11 18:55:27.000000000 +0100
59 @@ -434,7 +434,7 @@
60        return 0;
61     }
62  
63 -   if (len < 0)
64 +   if (len < 0) /* constant condition - size_t isn't ever negative */ 
65     {
66        return 1;
67     }
68 diff -urNad privoxy~/loadcfg.c privoxy/loadcfg.c
69 --- privoxy~/loadcfg.c  2006-02-11 18:55:17.000000000 +0100
70 +++ privoxy/loadcfg.c   2006-02-11 18:55:37.000000000 +0100
71 @@ -877,7 +877,7 @@
72                    MAX_AF_FILES);
73              }
74              config->re_filterfile_short[i] = strdup(arg);
75 -            p = malloc(strlen(arg));
76 +            p = malloc(strlen(arg) + 1);
77              if (p == NULL)
78              {
79                 log_error(LOG_LEVEL_FATAL, "Out of memory");
80 diff -urNad privoxy~/pcrs.c privoxy/pcrs.c
81 --- privoxy~/pcrs.c     2004-01-31 10:27:51.000000000 +0100
82 +++ privoxy/pcrs.c      2006-02-11 18:55:27.000000000 +0100
83 @@ -744,7 +744,7 @@
84  int pcrs_execute_list(pcrs_job *joblist, char *subject, size_t subject_length, char **result, size_t *result_length)
85  {
86     pcrs_job *job;
87 -   char *old, *new;
88 +   char *old, *new = NULL;
89     int hits, total_hits;
90   
91     old = subject;