neels has uploaded this change for review. (
https://gerrit.osmocom.org/c/libasn1c/+/37988?usp=email )
Change subject: coverity CID#27247 CID#27248
......................................................................
coverity CID#27247 CID#27248
Initialize local vars *after* null checking.
Change-Id: Id442fa5105828b81edc3bf85bd65957f248b9b52
---
M src/OCTET_STRING.c
M src/constr_CHOICE.c
2 files changed, 9 insertions(+), 6 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libasn1c refs/changes/88/37988/1
diff --git a/src/OCTET_STRING.c b/src/OCTET_STRING.c
index d8f0f69..8f5a697 100644
--- a/src/OCTET_STRING.c
+++ b/src/OCTET_STRING.c
@@ -2085,15 +2085,17 @@
void
OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) {
OCTET_STRING_t *st = (OCTET_STRING_t *)sptr;
- asn_OCTET_STRING_specifics_t *specs = td->specifics
- ? (asn_OCTET_STRING_specifics_t *)td->specifics
- : &asn_DEF_OCTET_STRING_specs;
- asn_struct_ctx_t *ctx = (asn_struct_ctx_t *)
- ((char *)st + specs->ctx_offset);
+ asn_OCTET_STRING_specifics_t *specs;
+ asn_struct_ctx_t *ctx;
struct _stack *stck;
if(!td || !st)
return;
+ specs = td->specifics
+ ? (asn_OCTET_STRING_specifics_t *)td->specifics
+ : &asn_DEF_OCTET_STRING_specs;
+ ctx = (asn_struct_ctx_t *)
+ ((char *)st + specs->ctx_offset);
ASN_DEBUG("Freeing %s as OCTET STRING", td->name);
diff --git a/src/constr_CHOICE.c b/src/constr_CHOICE.c
index df68feb..05e1182 100644
--- a/src/constr_CHOICE.c
+++ b/src/constr_CHOICE.c
@@ -1191,11 +1191,12 @@
void
CHOICE_free(asn_TYPE_descriptor_t *td, void *ptr, int contents_only) {
- asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics;
+ asn_CHOICE_specifics_t *specs;
int present;
if(!td || !ptr)
return;
+ specs = (asn_CHOICE_specifics_t *)td->specifics;
ASN_DEBUG("Freeing %s as CHOICE", td->name);
--
To view, visit
https://gerrit.osmocom.org/c/libasn1c/+/37988?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libasn1c
Gerrit-Branch: master
Gerrit-Change-Id: Id442fa5105828b81edc3bf85bd65957f248b9b52
Gerrit-Change-Number: 37988
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr(a)sysmocom.de>