#! /bin/sh /usr/share/dpatch/dpatch-run ## 13_memory.dpatch by David Schmidt ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: A few memory leaks plugged (mostly on error paths) ## DP: Removing a double free ## DP: Don't forget to malloc space for the null terminator... @DPATCH@ #diff -urNad privoxy~/cgisimple.c privoxy/cgisimple.c #--- privoxy~/cgisimple.c 2006-02-11 18:55:17.000000000 +0100 #+++ privoxy/cgisimple.c 2006-02-11 18:55:27.000000000 +0100 #@@ -880,12 +880,13 @@ # string_join (&s, html_encode(buf)); # } # fclose(fp); #- # if (map(exports, "contents", 1, s, 0)) # { #+ freez(s); # free_map(exports); # return JB_ERR_MEMORY; # } #+ freez(s); # } # # return template_fill_for_cgi(csp, "show-status-file", exports, rsp); #@@ -898,7 +899,7 @@ # if (!err) err = string_append(&s, " "); # } # if (!err) err = map(exports, "invocation", 1, s, 0); #- #+ freez(s); # if (!err) err = map(exports, "options", 1, csp->config->proxy_args, 1); # if (!err) err = show_defines(exports); # diff -urNad privoxy~/filters.c privoxy/filters.c --- privoxy~/filters.c 2006-02-11 18:55:17.000000000 +0100 +++ privoxy/filters.c 2006-02-11 18:55:27.000000000 +0100 @@ -966,6 +966,7 @@ string_append(&p, buf); } err = map(exports, "trusted-referrers", 1, p, 0); + freez(p); if (err) { @@ -988,6 +989,7 @@ string_append(&p, buf); } err = map(exports, "trust-info", 1, p, 0); + freez(p); } else { diff -urNad privoxy~/jbsockets.c privoxy/jbsockets.c --- privoxy~/jbsockets.c 2004-01-31 10:27:50.000000000 +0100 +++ privoxy/jbsockets.c 2006-02-11 18:55:27.000000000 +0100 @@ -434,7 +434,7 @@ return 0; } - if (len < 0) + if (len < 0) /* constant condition - size_t isn't ever negative */ { return 1; } diff -urNad privoxy~/loadcfg.c privoxy/loadcfg.c --- privoxy~/loadcfg.c 2006-02-11 18:55:17.000000000 +0100 +++ privoxy/loadcfg.c 2006-02-11 18:55:37.000000000 +0100 @@ -877,7 +877,7 @@ MAX_AF_FILES); } config->re_filterfile_short[i] = strdup(arg); - p = malloc(strlen(arg)); + p = malloc(strlen(arg) + 1); if (p == NULL) { log_error(LOG_LEVEL_FATAL, "Out of memory"); diff -urNad privoxy~/pcrs.c privoxy/pcrs.c --- privoxy~/pcrs.c 2004-01-31 10:27:51.000000000 +0100 +++ privoxy/pcrs.c 2006-02-11 18:55:27.000000000 +0100 @@ -744,7 +744,7 @@ int pcrs_execute_list(pcrs_job *joblist, char *subject, size_t subject_length, char **result, size_t *result_length) { pcrs_job *job; - char *old, *new; + char *old, *new = NULL; int hits, total_hits; old = subject;