TSequenceOf/TSetOf: Increase the length of the array after successful
decoding the next element, so that the array don't contain heap-data. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16084 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
		| @@ -396,17 +396,15 @@ decode_type (const char *name, const Type *t, int optional, | |||||||
| 		 "%s_tmp = realloc((%s)->val, " | 		 "%s_tmp = realloc((%s)->val, " | ||||||
| 		 "    sizeof(*((%s)->val)) * ((%s)->len + 1));\n" | 		 "    sizeof(*((%s)->val)) * ((%s)->len + 1));\n" | ||||||
| 		 "if (%s_tmp == NULL) { %s; }\n" | 		 "if (%s_tmp == NULL) { %s; }\n" | ||||||
| 		 "(%s)->len++;\n" |  | ||||||
| 		 "(%s)->val = %s_tmp;\n", | 		 "(%s)->val = %s_tmp;\n", | ||||||
| 		 tmpstr, tmpstr, tmpstr, | 		 tmpstr, tmpstr, tmpstr, | ||||||
| 		 name, name, | 		 name, name, | ||||||
| 		 tmpstr, tmpstr, | 		 tmpstr, tmpstr, | ||||||
| 		 name, name, name, | 		 name, name, name, | ||||||
| 		 tmpstr, | 		 tmpstr, forwstr,  | ||||||
| 		 forwstr, name, name, | 		 name, tmpstr); | ||||||
| 		 tmpstr); |  | ||||||
|  |  | ||||||
| 	asprintf (&n, "&(%s)->val[(%s)->len-1]", name, name); | 	asprintf (&n, "&(%s)->val[(%s)->len]", name, name); | ||||||
| 	if (n == NULL) | 	if (n == NULL) | ||||||
| 	    errx(1, "malloc"); | 	    errx(1, "malloc"); | ||||||
| 	asprintf (&sname, "%s_s_of", tmpstr); | 	asprintf (&sname, "%s_s_of", tmpstr); | ||||||
| @@ -414,10 +412,12 @@ decode_type (const char *name, const Type *t, int optional, | |||||||
| 	    errx(1, "malloc"); | 	    errx(1, "malloc"); | ||||||
| 	decode_type (n, t->subtype, 0, forwstr, sname); | 	decode_type (n, t->subtype, 0, forwstr, sname); | ||||||
| 	fprintf (codefile,  | 	fprintf (codefile,  | ||||||
|  | 		 "(%s)->len++;\n" | ||||||
| 		 "len = %s_origlen - ret;\n" | 		 "len = %s_origlen - ret;\n" | ||||||
| 		 "}\n" | 		 "}\n" | ||||||
| 		 "ret += %s_oldret;\n" | 		 "ret += %s_oldret;\n" | ||||||
| 		 "}\n", | 		 "}\n", | ||||||
|  | 		 name, | ||||||
| 		 tmpstr, tmpstr); | 		 tmpstr, tmpstr); | ||||||
| 	free (n); | 	free (n); | ||||||
| 	free (sname); | 	free (sname); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Love Hörnquist Åstrand
					Love Hörnquist Åstrand