asn1: Avoid malloc(0) also from BIT STRING and GENERALIZED TIME structures
This commit is contained in:
parent
e50bc29bd9
commit
cd51430ba7
|
@ -1464,11 +1464,13 @@ static int asn1_decode_entry(sc_context_t *ctx,struct sc_asn1_entry *entry,
|
|||
}
|
||||
if (entry->flags & SC_ASN1_ALLOC) {
|
||||
u8 **buf = (u8 **) parm;
|
||||
if (objlen > 1) {
|
||||
*buf = malloc(objlen-1);
|
||||
if (*buf == NULL) {
|
||||
r = SC_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*len = objlen-1;
|
||||
parm = *buf;
|
||||
}
|
||||
|
@ -1518,11 +1520,13 @@ static int asn1_decode_entry(sc_context_t *ctx,struct sc_asn1_entry *entry,
|
|||
assert(len != NULL);
|
||||
if (entry->flags & SC_ASN1_ALLOC) {
|
||||
u8 **buf = (u8 **) parm;
|
||||
if (objlen > 0) {
|
||||
*buf = malloc(objlen);
|
||||
if (*buf == NULL) {
|
||||
r = SC_ERROR_OUT_OF_MEMORY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
c = *len = objlen;
|
||||
parm = *buf;
|
||||
} else
|
||||
|
|
Loading…
Reference in New Issue