added stack control to PER
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@1022 59561ff5-6e30-0410-9f3c-9617f08c8826
diff --git a/skeletons/ber_tlv_length.c b/skeletons/ber_tlv_length.c
index 49343d3..f7342e7 100644
--- a/skeletons/ber_tlv_length.c
+++ b/skeletons/ber_tlv_length.c
@@ -84,17 +84,8 @@
/*
* Make sure we didn't exceed the maximum stack size.
*/
- if(opt_codec_ctx && opt_codec_ctx->max_stack_size) {
- ptrdiff_t usedstack = ((char *)opt_codec_ctx - (char *)&size);
- /* double negative is required to avoid int wrap-around */
- if(usedstack > 0) usedstack = -usedstack;
- ASN_DEBUG("Current stack size %ld", -(long)usedstack);
- if(usedstack < -(ptrdiff_t)opt_codec_ctx->max_stack_size) {
- ASN_DEBUG("Stack limit %ld reached",
- (long)opt_codec_ctx->max_stack_size);
- return -1;
- }
- }
+ if(_ASN_STACK_OVERFLOW_CHECK(opt_codec_ctx))
+ return -1;
/*
* Determine the size of L in TLV.