From 73a5cc65870e8a69c7aa086dd839a09b1c802d96 Mon Sep 17 00:00:00 2001
From: Lev Walkin <vlm@lionet.info>
Date: Sun, 24 Jun 2007 08:45:31 +0000
Subject: [PATCH] complex data

---
 asn1c/tests/check-126.-gen-PER.c | 24 ++++++++++++++++++++----
 skeletons/constr_SEQUENCE.c      |  5 ++---
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/asn1c/tests/check-126.-gen-PER.c b/asn1c/tests/check-126.-gen-PER.c
index 8217a64c..4d0775bf 100644
--- a/asn1c/tests/check-126.-gen-PER.c
+++ b/asn1c/tests/check-126.-gen-PER.c
@@ -238,14 +238,30 @@ compare_with_data_out(const char *fname, char *buf, int size) {
 
 	fprintf(stderr, "Comparing PER output with [%s]\n", outName);
 
-	if(strstr(outName, "-0-6-P.out")) {
+	if(strstr(outName, "-06-P.out")) {
+		f = fopen(outName, "w");
+		fbuf[0] = 0x81;
+		fbuf[1] = 0x40;
+		fbuf[2] = 0x00;
+		fwrite(fbuf, 1, 3, f);
+		fclose(f);
+	}
+
+	if(strstr(outName, "-07-P.out")) {
+		f = fopen(outName, "w");
+		fbuf[0] = 0x81;
+		fbuf[1] = 0x40;
+		fbuf[2] = 0x40;
+		fwrite(fbuf, 1, 3, f);
+		fclose(f);
+	}
+
+	if(strstr(outName, "-08-P.out")) {
 		f = fopen(outName, "w");
 		fbuf[0] = 0x81;
 		fbuf[1] = 0x40;
 		fbuf[2] = 0x80;
-		fbuf[3] = 0x00;
-		fbuf[4] = 0x00;
-		fwrite(fbuf, 1, 5, f);
+		fwrite(fbuf, 1, 3, f);
 		fclose(f);
 	}
 
diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c
index 5d099ae9..ec04992f 100644
--- a/skeletons/constr_SEQUENCE.c
+++ b/skeletons/constr_SEQUENCE.c
@@ -1249,6 +1249,7 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
 	}
 
 	/* Prepare a place and read-in the presence bitmap */
+	memset(&opmd, 0, sizeof(opmd));
 	if(specs->roms_count) {
 		opres = (uint8_t *)MALLOC(((specs->roms_count + 7) >> 3) + 1);
 		if(!opres) _ASN_DECODE_FAILED;
@@ -1258,13 +1259,11 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
 			_ASN_DECODE_STARVED;
 		}
 		opmd.buffer = opres;
-		opmd.nboff = 0;
 		opmd.nbits = specs->roms_count;
 		ASN_DEBUG("Read in presence bitmap for %s of %d bits (%x..)",
 			td->name, specs->roms_count, *opres);
 	} else {
 		opres = 0;
-		memset(&opmd, 0, sizeof opmd);
 	}
 
 	/*
@@ -1342,8 +1341,8 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
 		if(per_get_many_bits(pd, epres, 0, bmlength))
 			_ASN_DECODE_STARVED;
 
+		memset(&epmd, 0, sizeof(epmd));
 		epmd.buffer = epres;
-		epmd.nboff = 0;
 		epmd.nbits = bmlength;
 		ASN_DEBUG("Read in extensions bitmap for %s of %d bits (%x..)",
 			td->name, bmlength, *epres);
-- 
GitLab