From 93e6b5f8f49e61cd1153626afd3026efba19e1f1 Mon Sep 17 00:00:00 2001 From: Hans Petter Jansson Date: Tue, 18 Mar 2003 01:48:41 +0000 Subject: Part of fix for #34095 2003-03-17 Hans Petter Jansson Part of fix for #34095 * scripts/mkderivedparameters.pl: Generate code to free old string value when a new one is set. * src/libical/icalperiod.c (icalperiodtype_as_ical_string): Callers expect a temporary string, and thus won't free it, so allocate returned memory from the temporary ring. svn path=/trunk/; revision=20330 --- libical/ChangeLog | 11 +++++++++++ libical/scripts/mkderivedparameters.pl | 4 +++- libical/src/libical/icalperiod.c | 5 +++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libical/ChangeLog b/libical/ChangeLog index 0afb79e364..8d9542b7a3 100644 --- a/libical/ChangeLog +++ b/libical/ChangeLog @@ -1,3 +1,14 @@ +2003-03-17 Hans Petter Jansson + + Part of fix for #34095 + + * scripts/mkderivedparameters.pl: Generate code to free old + string value when a new one is set. + + * src/libical/icalperiod.c (icalperiodtype_as_ical_string): + Callers expect a temporary string, and thus won't free it, so + allocate returned memory from the temporary ring. + 2003-02-10 Ettore Perazzoli * src/libical/Makefile.am (libical_static_la_DEPENDENCIES): Make diff --git a/libical/scripts/mkderivedparameters.pl b/libical/scripts/mkderivedparameters.pl index 5772065ec4..89f25306a5 100755 --- a/libical/scripts/mkderivedparameters.pl +++ b/libical/scripts/mkderivedparameters.pl @@ -188,7 +188,9 @@ foreach $param (keys %params){ $charorenum = " icalerror_check_arg_rz( (param!=0), \"param\");\n return ($type)((struct icalparameter_impl*)param)->string;"; - $set_code = "((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);"; + $set_code = "if (((struct icalparameter_impl*)param)->string != 0)\n" . + " free((void *) ((struct icalparameter_impl*)param)->string);\n" . + " ((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);"; $pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");"; $pointer_check_v = "icalerror_check_arg_rv( (v!=0),\"v\");"; diff --git a/libical/src/libical/icalperiod.c b/libical/src/libical/icalperiod.c index 6117df526f..b8c8cad1a5 100644 --- a/libical/src/libical/icalperiod.c +++ b/libical/src/libical/icalperiod.c @@ -137,8 +137,9 @@ const char* icalperiodtype_as_ical_string(struct icalperiodtype p) icalmemory_append_string(&buf, &buf_ptr, &buf_size, end); - - return buf; + buf_ptr = icalmemory_tmp_copy (buf); + icalmemory_free_buffer (buf); + return buf_ptr; } -- cgit