some reentrancy protection
diff --git a/skeletons/asn_internal.h b/skeletons/asn_internal.h
index 9866962..55e4e2b 100644
--- a/skeletons/asn_internal.h
+++ b/skeletons/asn_internal.h
@@ -37,8 +37,10 @@
#ifdef __GNUC__
#ifdef ASN_THREAD_SAFE
#define asn_debug_indent 0
+#define ASN_DEBUG_INDENT_ADD(i) do{}while(0)
#else /* !ASN_THREAD_SAFE */
int asn_debug_indent;
+#define ASN_DEBUG_INDENT_ADD(i) do { asn_debug_indent += increment; } while(0)
#endif /* ASN_THREAD_SAFE */
#define ASN_DEBUG(fmt, args...) do { \
int adi = asn_debug_indent; \
diff --git a/skeletons/per_opentype.c b/skeletons/per_opentype.c
index ebcf076..03a31d2 100644
--- a/skeletons/per_opentype.c
+++ b/skeletons/per_opentype.c
@@ -18,8 +18,6 @@
static int per_skip_bits(asn_per_data_t *pd, int skip_nbits);
static asn_dec_rval_t uper_sot_suck(asn_codec_ctx_t *, asn_TYPE_descriptor_t *td, asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd);
-int asn_debug_indent;
-
/*
* Encode an "open type field".
* #10.1, #10.2
@@ -101,9 +99,9 @@
spd.buffer = buf;
spd.nbits = bufLen << 3;
- asn_debug_indent += 4;
+ ASN_DEBUG_INDENT_ADD(+4);
rv = td->uper_decoder(ctx, td, constraints, sptr, &spd);
- asn_debug_indent -= 4;
+ ASN_DEBUG_INDENT_ADD(-4);
if(rv.code == RC_OK) {
/* Check padding validity */
@@ -153,9 +151,9 @@
pd->nbits = pd->nboff; /* 0 good bits at this point, will refill */
pd->moved = 0; /* This now counts the open type size in bits */
- asn_debug_indent += 4;
+ ASN_DEBUG_INDENT_ADD(+4);
rv = td->uper_decoder(ctx, td, constraints, sptr, pd);
- asn_debug_indent -= 4;
+ ASN_DEBUG_INDENT_ADD(-4);
#define UPDRESTOREPD do { \
/* buffer and nboff are valid, preserve them. */ \