X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/46b0747592074017ff0ea4b33d4a7194235886e5..e3e2d6326db86d7ca22d2cba1193aa64a8e33b2d:/libs/smux/der_encoder.c?ds=sidebyside diff --git a/libs/smux/der_encoder.c b/libs/smux/der_encoder.c index 6c859e1b..1c014802 100644 --- a/libs/smux/der_encoder.c +++ b/libs/smux/der_encoder.c @@ -80,8 +80,8 @@ der_write_tags(asn_TYPE_descriptor_t *sd, ber_tlv_tag_t tag, /* EXPLICIT or IMPLICIT tag */ asn_app_consume_bytes_f *cb, void *app_key) { - ber_tlv_tag_t *tags; /* Copy of tags stream */ - int tags_count; /* Number of tags */ + const ber_tlv_tag_t *tags; /* Copy of tags stream */ + int tags_count; /* Number of tags */ size_t overall_length; ssize_t *lens; int i; @@ -102,8 +102,9 @@ der_write_tags(asn_TYPE_descriptor_t *sd, * and initialize it appropriately. */ int stag_offset; - tags = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t)); - if(!tags) { /* Can fail on !x86 */ + ber_tlv_tag_t *tags_buf; + tags_buf = (ber_tlv_tag_t *)alloca((sd->tags_count + 1) * sizeof(ber_tlv_tag_t)); + if(!tags_buf) { /* Can fail on !x86 */ errno = ENOMEM; return -1; } @@ -111,10 +112,11 @@ der_write_tags(asn_TYPE_descriptor_t *sd, + 1 /* EXPLICIT or IMPLICIT tag is given */ - ((tag_mode == -1) && sd->tags_count); /* Copy tags over */ - tags[0] = tag; + tags_buf[0] = tag; stag_offset = -1 + ((tag_mode == -1) && sd->tags_count); for(i = 1; i < tags_count; i++) - tags[i] = sd->tags[i + stag_offset]; + tags_buf[i] = sd->tags[i + stag_offset]; + tags = tags_buf; } else { tags = sd->tags; tags_count = sd->tags_count;