yin parser BUGFIX avoid calling calloc with size 0
Fixes #1318
diff --git a/src/parser_yin.c b/src/parser_yin.c
index 57f2d10..62f6857 100644
--- a/src/parser_yin.c
+++ b/src/parser_yin.c
@@ -673,8 +673,10 @@
}
}
- type->info.bits.bit = calloc(type->info.bits.count, sizeof *type->info.bits.bit);
- LY_CHECK_ERR_GOTO(!type->info.bits.bit, LOGMEM(ctx), error);
+ if (type->info.bits.count) {
+ type->info.bits.bit = calloc(type->info.bits.count, sizeof *type->info.bits.bit);
+ LY_CHECK_ERR_GOTO(!type->info.bits.bit, LOGMEM(ctx), error);
+ }
p = 0;
i = 0;
@@ -968,8 +970,10 @@
}
}
- type->info.enums.enm = calloc(type->info.enums.count, sizeof *type->info.enums.enm);
- LY_CHECK_ERR_GOTO(!type->info.enums.enm, LOGMEM(ctx), error);
+ if (type->info.enums.count) {
+ type->info.enums.enm = calloc(type->info.enums.count, sizeof *type->info.enums.enm);
+ LY_CHECK_ERR_GOTO(!type->info.enums.enm, LOGMEM(ctx), error);
+ }
v = 0;
i = 0;