Browse code

core: config parser minor fix

- use a pkg_malloc'ed copy of yy_number_str for host_if_id
- always free ID/NUM_ID/host_if_id after copying them (bug
introduced in the last merge)

Andrei Pelinescu-Onciul authored on 17/07/2009 16:15:44
Showing 1 changed files
... ...
@@ -1932,6 +1932,7 @@ host:
1932 1932
 			}
1933 1933
 			pkg_free($1);
1934 1934
 		}
1935
+		if ($3) pkg_free($3);
1935 1936
 	}
1936 1937
 	| host MINUS ID {
1937 1938
 		if ($1){
... ...
@@ -1947,6 +1948,7 @@ host:
1947 1948
 			}
1948 1949
 			pkg_free($1);
1949 1950
 		}
1951
+		if ($3) pkg_free($3);
1950 1952
 	}
1951 1953
 	| host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
1952 1954
 	| host MINUS error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
... ...
@@ -1954,7 +1956,12 @@ host:
1954 1956
 
1955 1957
 host_if_id: ID
1956 1958
 		| NUM_ID
1957
-		| NUMBER { $$=yy_number_str /* text version */; }
1959
+		| NUMBER {
1960
+			/* get string version */
1961
+			$$=pkg_malloc(strlen(yy_number_str)+1);
1962
+			if ($$)
1963
+				strcpy($$, yy_number_str);
1964
+		}
1958 1965
 		;
1959 1966
 
1960 1967
 host_or_if:
... ...
@@ -1973,6 +1980,7 @@ host_or_if:
1973 1980
 			}
1974 1981
 			pkg_free($1);
1975 1982
 		}
1983
+		if ($3) pkg_free($3);
1976 1984
 	}
1977 1985
 	| host_or_if MINUS host_if_id {
1978 1986
 		if ($1){
... ...
@@ -1988,6 +1996,7 @@ host_or_if:
1988 1996
 			}
1989 1997
 			pkg_free($1);
1990 1998
 		}
1999
+		if ($3) pkg_free($3);
1991 2000
 	}
1992 2001
 	| host_or_if DOT error { $$=0; pkg_free($1);
1993 2002
 								yyerror("invalid host or interface name"); }