diff --git a/skeletons/asn_internal.h b/skeletons/asn_internal.h
index 67f055a62fbf74c397d2c108469549291ef9e6af..ff63277863c0dfdb5a301875a358caf59844a641 100644
--- a/skeletons/asn_internal.h
+++ b/skeletons/asn_internal.h
@@ -70,6 +70,7 @@ static inline void ASN_DEBUG(const char *fmt, ...) { (void)fmt; }
 	int __nl = ((nl) != 0);						\
 	int __i;							\
 	if(__nl) _ASN_CALLBACK("\n", 1);				\
+	if(__level < 0) __level = 0;					\
 	for(__i = 0; __i < __level; __i++)				\
 		_ASN_CALLBACK("    ", 4);				\
 	er.encoded += __nl + 4 * __level;				\