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 1947
 			}
1948 1948
 			pkg_free($1);
1949 1949
 		}
1950
+		if ($3) pkg_free($3);
1950 1951
 	}
1951 1952
 	| host DOT error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
1952 1953
 	| host MINUS error { $$=0; pkg_free($1); yyerror("invalid hostname"); }
... ...
@@ -1954,7 +1956,12 @@ host:
1954 1954
 
1955 1955
 host_if_id: ID
1956 1956
 		| NUM_ID
1957
-		| NUMBER { $$=yy_number_str /* text version */; }
1957
+		| NUMBER {
1958
+			/* get string version */
1959
+			$$=pkg_malloc(strlen(yy_number_str)+1);
1960
+			if ($$)
1961
+				strcpy($$, yy_number_str);
1962
+		}
1958 1963
 		;
1959 1964
 
1960 1965
 host_or_if:
... ...
@@ -1973,6 +1980,7 @@ host_or_if:
1973 1973
 			}
1974 1974
 			pkg_free($1);
1975 1975
 		}
1976
+		if ($3) pkg_free($3);
1976 1977
 	}
1977 1978
 	| host_or_if MINUS host_if_id {
1978 1979
 		if ($1){
... ...
@@ -1988,6 +1996,7 @@ host_or_if:
1988 1988
 			}
1989 1989
 			pkg_free($1);
1990 1990
 		}
1991
+		if ($3) pkg_free($3);
1991 1992
 	}
1992 1993
 	| host_or_if DOT error { $$=0; pkg_free($1);
1993 1994
 								yyerror("invalid host or interface name"); }