its ok to return NULL if we are allocating zero elements

This commit is contained in:
Love Hornquist Astrand
2009-10-11 15:38:21 -07:00
parent 1e9ec73bbc
commit 102cd04b0d

View File

@@ -630,7 +630,7 @@ decode_type (const char *name, const Type *t, int optional,
fprintf(codefile,
"else {\n"
"(%s)->u.%s.data = calloc(1, len);\n"
"if ((%s)->u.%s.data == NULL) {\n"
"if ((%s)->u.%s.data == NULL && len != 0) {\n"
"e = ENOMEM; %s;\n"
"}\n"
"(%s)->u.%s.length = len;\n"