libical r637 - in trunk: . src/libical



Author: pchen
Date: Thu Feb 28 07:06:47 2008
New Revision: 637
URL: http://svn.gnome.org/viewvc/libical?rev=637&view=rev

Log:
2008-02-28  Chenthill Palanisamy  <pchenthill novell com>

        Fixes #518744
        * src/libical/icalparser.c: (make_segment),
        (icalparser_get_prop_name), (icalparser_get_param_name),
        (icalparser_get_next_paramvalue), (icalparser_get_next_value),
        (icalparser_get_next_parameter), (icalparser_add_line): Do not
        allocate memory in tmp buffer for get_param_name function.                                                              



Modified:
   trunk/ChangeLog
   trunk/src/libical/icalparser.c

Modified: trunk/src/libical/icalparser.c
==============================================================================
--- trunk/src/libical/icalparser.c	(original)
+++ trunk/src/libical/icalparser.c	Thu Feb 28 07:06:47 2008
@@ -200,12 +200,15 @@
 
 
 /** make a new tmp buffer out of a substring */
-static char* make_segment(char* start, char* end)
+static char* make_segment(char* start, char* end, int tmp_buffer)
 {
     char *buf, *tmp;
     size_t size = (size_t)end - (size_t)start;
     
-    buf = icalmemory_tmp_buffer(size+1);
+    if (tmp_buffer)
+	    buf = icalmemory_tmp_buffer(size+1);
+    else
+	    buf = icalmemory_new_buffer (size+1);
     
 
     strncpy(buf,start,size);
@@ -237,10 +240,10 @@
     /* There is no ';' or, it is after the ';' that marks the beginning of
        the value */
     if (v!=0 && ( p == 0 || p > v)){
-	str = make_segment(line,v);
+	str = make_segment(line,v, 1);
 	*end = v+1;
     } else {
-	str = make_segment(line,p);
+	str = make_segment(line,p, 1);
 	*end = p+1;
     }
 
@@ -259,7 +262,7 @@
 	return 0;
     }
 
-    str = make_segment(line,next);
+    str = make_segment(line,next, 0);
     *end = next+1;
     if (**end == '"') {
         *end = *end+1;
@@ -268,8 +271,9 @@
 		    return 0;
 	    }
 
-	    *end = make_segment(*end,next);
-    }
+	    *end = make_segment(*end,next, 0);
+    } else
+	   *end = strdup (*end);
 
     return str;
 }
@@ -289,7 +293,7 @@
     if (next == line){
 	return 0;
     } else {
-	str = make_segment(line,next);
+	str = make_segment(line,next, 1);
 	*end = next+1;
 	return str;
     }
@@ -372,7 +376,7 @@
     } 
 	
 
-    str = make_segment(line,next);
+    str = make_segment(line,next, 1);
     return str;
    
 }
@@ -394,7 +398,7 @@
     }
 
     if (next != 0) {
-	str = make_segment(line,next);
+	str = make_segment(line,next, 1);
 	*end = next+1;
 	return str;
     } else {
@@ -825,8 +829,8 @@
 	str = strstrip (str);
 
 	if (str != 0){
-	    char* name;
-	    char* pvalue;
+	    char* name = 0;
+	    char* pvalue = 0;
         
 	    icalparameter *param = 0;
 	    icalparameter_kind kind;
@@ -862,8 +866,17 @@
 			     ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR);
 		tail = 0;
 		parser->state = ICALPARSER_ERROR;
+	    	if (pvalue)
+			free (pvalue);
+		if (name)
+		        free (name);
+			
 		continue;
 	    }
+	    if (pvalue)
+		    free (pvalue);
+	    if (name)
+		    free (name);
 
 	    if (param == 0){
 		/* 'tail' defined above */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]