diff options
author | Matthieu Patou <mat@matws.net> | 2010-08-15 18:31:28 +0400 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2010-10-03 01:15:04 +0000 |
commit | ab6e3fce040f9ad27cbce44e9038a24f15b601c8 (patch) | |
tree | ab99a431c9610927b5d0d26335d2712b509fd6dc /source4/heimdal/lib/asn1/gen_copy.c | |
parent | 197a1514d62494cc8b862d169c841a26e04b8925 (diff) | |
download | samba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.tar.gz samba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.tar.bz2 samba-ab6e3fce040f9ad27cbce44e9038a24f15b601c8.zip |
s4:heimdal: import lorikeet-heimdal-201009250123 (commit 42cabfb5b683dbcb97d583c397b897507689e382)
I based this on Matthieu's import of lorikeet-heimdal, and then
updated it to this commit.
Andrew Bartlett
Diffstat (limited to 'source4/heimdal/lib/asn1/gen_copy.c')
-rw-r--r-- | source4/heimdal/lib/asn1/gen_copy.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/source4/heimdal/lib/asn1/gen_copy.c b/source4/heimdal/lib/asn1/gen_copy.c index 5e228d0e64..36f68ee5d9 100644 --- a/source4/heimdal/lib/asn1/gen_copy.c +++ b/source4/heimdal/lib/asn1/gen_copy.c @@ -110,14 +110,16 @@ copy_type (const char *from, const char *to, const Type *t, int preserve) if(t->type == TChoice) fprintf(codefile, "case %s:\n", m->label); - asprintf (&fs, "%s(%s)->%s%s", - m->optional ? "" : "&", from, - t->type == TChoice ? "u." : "", m->gen_name); + if (asprintf (&fs, "%s(%s)->%s%s", + m->optional ? "" : "&", from, + t->type == TChoice ? "u." : "", m->gen_name) < 0) + errx(1, "malloc"); if (fs == NULL) errx(1, "malloc"); - asprintf (&ts, "%s(%s)->%s%s", - m->optional ? "" : "&", to, - t->type == TChoice ? "u." : "", m->gen_name); + if (asprintf (&ts, "%s(%s)->%s%s", + m->optional ? "" : "&", to, + t->type == TChoice ? "u." : "", m->gen_name) < 0) + errx(1, "malloc"); if (ts == NULL) errx(1, "malloc"); if(m->optional){ @@ -155,8 +157,7 @@ copy_type (const char *from, const char *to, const Type *t, int preserve) } case TSetOf: case TSequenceOf: { - char *f; - char *T; + char *f = NULL, *T = NULL; fprintf (codefile, "if(((%s)->val = " "malloc((%s)->len * sizeof(*(%s)->val))) == NULL && (%s)->len != 0)\n", @@ -166,10 +167,12 @@ copy_type (const char *from, const char *to, const Type *t, int preserve) fprintf(codefile, "for((%s)->len = 0; (%s)->len < (%s)->len; (%s)->len++){\n", to, to, from, to); - asprintf(&f, "&(%s)->val[(%s)->len]", from, to); + if (asprintf(&f, "&(%s)->val[(%s)->len]", from, to) < 0) + errx(1, "malloc"); if (f == NULL) errx(1, "malloc"); - asprintf(&T, "&(%s)->val[(%s)->len]", to, to); + if (asprintf(&T, "&(%s)->val[(%s)->len]", to, to) < 0) + errx(1, "malloc"); if (T == NULL) errx(1, "malloc"); copy_type(f, T, t->subtype, FALSE); @@ -228,7 +231,7 @@ generate_type_copy (const Symbol *s) used_fail = 0; - fprintf (codefile, "int\n" + fprintf (codefile, "int ASN1CALL\n" "copy_%s(const %s *from, %s *to)\n" "{\n" "memset(to, 0, sizeof(*to));\n", |