more robust pre-allocation; credits to Yuriy Olkhovyy
diff --git a/skeletons/INTEGER.c b/skeletons/INTEGER.c
index e7a5ba6..c6e1d91 100644
--- a/skeletons/INTEGER.c
+++ b/skeletons/INTEGER.c
@@ -339,6 +339,9 @@
ASN_DEBUG("INTEGER body %ld 0x%2x..0x%2x",
(long)chunk_size, *lstart, lstop[-1]);
+ if(INTEGER_st_prealloc(st, (chunk_size/3) + 1))
+ return XPBD_SYSTEM_FAILURE;
+
/*
* We may have received a tag here. It will be processed inline.
* Use strtoul()-like code and serialize the result.
@@ -447,8 +450,6 @@
* places as a decimal value.
* Switch decoding mode. */
ASN_DEBUG("INTEGER re-evaluate as hex form");
- if(INTEGER_st_prealloc(st, (chunk_size/3) + 1))
- return XPBD_SYSTEM_FAILURE;
state = ST_SKIPSPHEX;
lp = lstart - 1;
continue;
@@ -476,8 +477,6 @@
continue;
case ST_DIGITS:
ASN_DEBUG("INTEGER re-evaluate as hex form");
- if(INTEGER_st_prealloc(st, (chunk_size/3) + 1))
- return XPBD_SYSTEM_FAILURE;
state = ST_SKIPSPHEX;
lp = lstart - 1;
continue;