aboutsummaryrefslogtreecommitdiffstats
path: root/skeletons/OCTET_STRING.c
diff options
context:
space:
mode:
authorvlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2005-02-14 17:21:22 +0000
committervlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2005-02-14 17:21:22 +0000
commit390a90244c74f538b8c2806d88d1dae01b7eba0f (patch)
tree5342fb6d9b59a2e15de7c1bda1b5582ab5ef0a59 /skeletons/OCTET_STRING.c
parent90f0faa878e969ca417584c215175d9a4fbd7649 (diff)
more XER decoding
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@633 59561ff5-6e30-0410-9f3c-9617f08c8826
Diffstat (limited to 'skeletons/OCTET_STRING.c')
-rw-r--r--skeletons/OCTET_STRING.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/skeletons/OCTET_STRING.c b/skeletons/OCTET_STRING.c
index d1b08741..a9c591d9 100644
--- a/skeletons/OCTET_STRING.c
+++ b/skeletons/OCTET_STRING.c
@@ -1103,26 +1103,34 @@ OCTET_STRING__decode_xer(asn_codec_ctx_t *opt_codec_ctx,
(void *struct_ptr, void *chunk_buf, size_t chunk_size,
int have_more)
) {
+ OCTET_STRING_t *st = *sptr;
asn_OCTET_STRING_specifics_t *specs = td->specifics
? (asn_OCTET_STRING_specifics_t *)td->specifics
: &asn_DEF_OCTET_STRING_specs;
const char *xml_tag = opt_mname ? opt_mname : td->xml_tag;
asn_struct_ctx_t *ctx; /* Per-structure parser context */
+ asn_dec_rval_t rval; /* Return value from the decoder */
+ int st_allocated;
/*
* Create the string if does not exist.
*/
- if(!*sptr) {
- OCTET_STRING_t *st;
+ if(!st) {
st = (OCTET_STRING_t *)CALLOC(1, specs->struct_size);
- if(st) st->buf = (uint8_t *)CALLOC(1, 1);
*sptr = (void *)st;
- if(!st || !st->buf) {
- asn_dec_rval_t rval;
- if(*sptr) FREEMEM(*sptr);
- rval.code = RC_FAIL;
- rval.consumed = 0;
- return rval;
+ if(!st) goto sta_failed;
+ st_allocated = 1;
+ } else st_allocated = 0;
+ if(!st->buf) {
+ /* This is separate from above section */
+ st->buf = (uint8_t *)CALLOC(1, 1);
+ if(!st->buf) {
+ if(st_allocated) {
+ *sptr = 0;
+ goto stb_failed;
+ } else {
+ goto sta_failed;
+ }
}
}
@@ -1131,6 +1139,13 @@ OCTET_STRING__decode_xer(asn_codec_ctx_t *opt_codec_ctx,
return xer_decode_general(opt_codec_ctx, ctx, *sptr, xml_tag,
buf_ptr, size, opt_unexpected_tag_decoder, body_receiver);
+
+stb_failed:
+ FREEMEM(st);
+sta_failed:
+ rval.code = RC_FAIL;
+ rval.consumed = 0;
+ return rval;
}
/*