Commit a636e930 authored by Raphael Defosseux's avatar Raphael Defosseux

CPPCHECK: fix a few errors

Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parent 30f09822
......@@ -47,7 +47,7 @@ class ABBA {
private:
uint8_t _iei;
uint8_t _length;
uint8_t _value[255];
uint8_t _value[256];
};
} // namespace nas
......
......@@ -1146,7 +1146,7 @@ asn_enc_rval_t CHOICE_encode_aper(
return elm->type->op->aper_encoder(
elm->type, elm->encoding_constraints.per_constraints, memb_ptr, po);
} else {
} else if (ct) {
asn_enc_rval_t rval;
if (specs->ext_start == -1) ASN__ENCODE_FAILED;
if (aper_put_nsnnwn(po, ct->range_bits, present - specs->ext_start))
......@@ -1156,6 +1156,8 @@ asn_enc_rval_t CHOICE_encode_aper(
ASN__ENCODE_FAILED;
rval.encoded = 0;
ASN__ENCODED_OK(rval);
} else {
ASN__ENCODE_FAILED;
}
}
......
......@@ -164,7 +164,8 @@ int balloc(bstring b, int olen) {
#if defined(BSTRLIB_TEST_CANARY)
if (len > b->slen + 1) {
memchr(b->data + b->slen + 1, 'X', len - (b->slen + 1));
if ((memchr(b->data + b->slen + 1, 'X', len - (b->slen + 1))) == NULL)
return BSTR_ERR;
}
#endif
}
......@@ -218,7 +219,8 @@ bstring bfromcstr(const char* str) {
b = (bstring) bstr__alloc(sizeof(struct tagbstring));
if (NULL == b) return NULL;
b->slen = (int) j;
if (NULL == (b->data = (unsigned char*) bstr__alloc(b->mlen = i))) {
b->data = (unsigned char*) bstr__alloc(b->mlen = i);
if (b->data == NULL) {
bstr__free(b);
return NULL;
}
......@@ -1588,7 +1590,8 @@ int binsertblk(
/* Aliasing case */
if (((size_t)((unsigned char*) blk + len)) >= ((size_t) b->data) &&
((size_t) blk) < ((size_t)(b->data + b->mlen))) {
if (NULL == (aux = (unsigned char*) bstr__alloc(len))) return BSTR_ERR;
aux = (unsigned char*) bstr__alloc(len);
if (aux == NULL) return BSTR_ERR;
bstr__memcpy(aux, blk, len);
}
......@@ -2133,6 +2136,9 @@ int bsreadlna(bstring r, struct bStream* s, char terminator) {
int i, l, ret, rlo;
char* b;
struct tagbstring x;
x.mlen = 0;
x.slen = 0;
x.data = NULL;
if (s == NULL || s->buff == NULL || r == NULL || r->mlen <= 0 ||
r->slen < 0 || r->mlen < r->slen)
......@@ -2201,6 +2207,9 @@ int bsreadlnsa(bstring r, struct bStream* s, const_bstring term) {
unsigned char* b;
struct tagbstring x;
struct charField cf;
x.mlen = 0;
x.slen = 0;
x.data = NULL;
if (s == NULL || s->buff == NULL || r == NULL || term == NULL ||
term->data == NULL || r->mlen <= 0 || r->slen < 0 || r->mlen < r->slen)
......@@ -2470,7 +2479,10 @@ bstring bjoinblk(const struct bstrList* bl, const void* blk, int len) {
* NULL is returned, otherwise a bstring with the correct result is returned.
*/
bstring bjoin(const struct bstrList* bl, const_bstring sep) {
if (sep != NULL && (sep->slen < 0 || sep->data == NULL)) return NULL;
if (sep == NULL)
return NULL;
else if (sep->slen < 0 || sep->data == NULL)
return NULL;
return bjoinblk(bl, sep->data, sep->slen);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment