catch error from as.*printf
This commit is contained in:
@@ -149,10 +149,9 @@ length_type (const char *name, const Type *t,
|
||||
if(t->type == TChoice)
|
||||
fprintf(codefile, "case %s:\n", m->label);
|
||||
|
||||
asprintf (&s, "%s(%s)->%s%s",
|
||||
m->optional ? "" : "&", name,
|
||||
t->type == TChoice ? "u." : "", m->gen_name);
|
||||
if (s == NULL)
|
||||
if (asprintf (&s, "%s(%s)->%s%s",
|
||||
m->optional ? "" : "&", name,
|
||||
t->type == TChoice ? "u." : "", m->gen_name) < 0 || s == NULL)
|
||||
errx(1, "malloc");
|
||||
if (m->optional)
|
||||
fprintf (codefile, "if(%s)", s);
|
||||
@@ -183,8 +182,8 @@ length_type (const char *name, const Type *t,
|
||||
}
|
||||
case TSetOf:
|
||||
case TSequenceOf: {
|
||||
char *n;
|
||||
char *sname;
|
||||
char *n = NULL;
|
||||
char *sname = NULL;
|
||||
|
||||
fprintf (codefile,
|
||||
"{\n"
|
||||
@@ -196,11 +195,9 @@ length_type (const char *name, const Type *t,
|
||||
fprintf (codefile, "for(i = (%s)->len - 1; i >= 0; --i){\n", name);
|
||||
fprintf (codefile, "int %s_for_oldret = %s;\n"
|
||||
"%s = 0;\n", tmpstr, variable, variable);
|
||||
asprintf (&n, "&(%s)->val[i]", name);
|
||||
if (n == NULL)
|
||||
if (asprintf (&n, "&(%s)->val[i]", name) < 0 || n == NULL)
|
||||
errx(1, "malloc");
|
||||
asprintf (&sname, "%s_S_Of", tmpstr);
|
||||
if (sname == NULL)
|
||||
if (asprintf (&sname, "%s_S_Of", tmpstr) < 0 || sname == NULL)
|
||||
errx(1, "malloc");
|
||||
length_type(n, t->subtype, variable, sname);
|
||||
fprintf (codefile, "%s += %s_for_oldret;\n",
|
||||
@@ -248,9 +245,8 @@ length_type (const char *name, const Type *t,
|
||||
fprintf (codefile, "/* NULL */\n");
|
||||
break;
|
||||
case TTag:{
|
||||
char *tname;
|
||||
asprintf(&tname, "%s_tag", tmpstr);
|
||||
if (tname == NULL)
|
||||
char *tname = NULL;
|
||||
if (asprintf(&tname, "%s_tag", tmpstr) < 0 || tname == NULL)
|
||||
errx(1, "malloc");
|
||||
length_type (name, t->subtype, variable, tname);
|
||||
fprintf (codefile, "ret += %lu + der_length_len (ret);\n",
|
||||
|
@@ -224,7 +224,8 @@ partial_offset(const char *basetype, const char *name, int need_offset)
|
||||
char *str;
|
||||
if (name == NULL || need_offset == 0)
|
||||
return strdup("0");
|
||||
asprintf(&str, "offsetof(struct %s, %s)", basetype, name);
|
||||
if (asprintf(&str, "offsetof(struct %s, %s)", basetype, name) < 0 || str == NULL)
|
||||
errx(1, "malloc");
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -273,7 +274,8 @@ tlist_header(struct tlist *t, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vasprintf(&t->header, fmt, ap);
|
||||
if (vasprintf(&t->header, fmt, ap) < 0 || t->header == NULL)
|
||||
errx(1, "malloc");
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
@@ -389,7 +391,8 @@ add_line(struct templatehead *t, const char *fmt, ...)
|
||||
struct template *q = calloc(1, sizeof(*q));
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vasprintf(&q->line, fmt, ap);
|
||||
if (vasprintf(&q->line, fmt, ap) < 0 || q->line == NULL)
|
||||
errx(1, "malloc");
|
||||
va_end(ap);
|
||||
ASN1_TAILQ_INSERT_TAIL(t, q, members);
|
||||
return q;
|
||||
@@ -404,10 +407,11 @@ add_line_pointer(struct templatehead *t,
|
||||
{
|
||||
struct template *q;
|
||||
va_list ap;
|
||||
char *tt;
|
||||
char *tt = NULL;
|
||||
|
||||
va_start(ap, ttfmt);
|
||||
vasprintf(&tt, ttfmt, ap);
|
||||
if (vasprintf(&tt, ttfmt, ap) < 0 || tt == NULL)
|
||||
errx(1, "malloc");
|
||||
va_end(ap);
|
||||
|
||||
q = add_line(t, "{ %s, %s, asn1_%s }", tt, offset, ptr);
|
||||
@@ -543,7 +547,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
|
||||
struct template *q;
|
||||
Member *m;
|
||||
size_t count = 0, i;
|
||||
char *bname;
|
||||
char *bname = NULL;
|
||||
FILE *f = get_code_file();
|
||||
|
||||
if (ASN1_TAILQ_EMPTY(t->members)) {
|
||||
@@ -551,7 +555,8 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
|
||||
break;
|
||||
}
|
||||
|
||||
asprintf(&bname, "bmember_%s_%lu", name ? name : "", (unsigned long)t);
|
||||
if (asprintf(&bname, "bmember_%s_%lu", name ? name : "", (unsigned long)t) < 0 || bname == NULL)
|
||||
errx(1, "malloc");
|
||||
output_name(bname);
|
||||
|
||||
ASN1_TAILQ_FOREACH(m, t->members, members) {
|
||||
@@ -584,7 +589,7 @@ template_members(struct templatehead *temp, const char *basetype, const char *na
|
||||
|
||||
ASN1_TAILQ_FOREACH(m, t->members, members) {
|
||||
char *newbasename = NULL;
|
||||
|
||||
|
||||
if (m->ellipsis)
|
||||
continue;
|
||||
|
||||
|
Reference in New Issue
Block a user