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, "
|
||||
" sizeof(*((%s)->val)) * ((%s)->len + 1));\n"
|
||||
"if (%s_tmp == NULL) { %s; }\n"
|
||||
"(%s)->len++;\n"
|
||||
"(%s)->val = %s_tmp;\n",
|
||||
tmpstr, tmpstr, tmpstr,
|
||||
name, name,
|
||||
tmpstr, tmpstr,
|
||||
name, name, name,
|
||||
tmpstr,
|
||||
forwstr, name, name,
|
||||
tmpstr);
|
||||
tmpstr, forwstr,
|
||||
name, tmpstr);
|
||||
|
||||
asprintf (&n, "&(%s)->val[(%s)->len-1]", name, name);
|
||||
asprintf (&n, "&(%s)->val[(%s)->len]", name, name);
|
||||
if (n == NULL)
|
||||
errx(1, "malloc");
|
||||
asprintf (&sname, "%s_s_of", tmpstr);
|
||||
@@ -414,10 +412,12 @@ decode_type (const char *name, const Type *t, int optional,
|
||||
errx(1, "malloc");
|
||||
decode_type (n, t->subtype, 0, forwstr, sname);
|
||||
fprintf (codefile,
|
||||
"(%s)->len++;\n"
|
||||
"len = %s_origlen - ret;\n"
|
||||
"}\n"
|
||||
"ret += %s_oldret;\n"
|
||||
"}\n",
|
||||
name,
|
||||
tmpstr, tmpstr);
|
||||
free (n);
|
||||
free (sname);
|
||||
|
Reference in New Issue
Block a user