mirror of https://github.com/ARMmbed/mbed-os.git
NFC-URI: fix passing null pointer to a function.
Fixes Coverity issue about passing nullptr to memcpy.pull/11551/head
parent
24cb0334eb
commit
081183c11e
|
@ -40,16 +40,20 @@ URI::URI(uri_identifier_code_t id, const Span<const uint8_t> &uri_field) :
|
|||
_uri(uri_field.size() ? new uint8_t[uri_id_code_size + uri_field.size()] : NULL),
|
||||
_uri_size(uri_id_code_size + uri_field.size())
|
||||
{
|
||||
if (_uri) {
|
||||
_uri[uri_id_index] = id;
|
||||
memcpy(_uri + uri_field_index, uri_field.data(), uri_field.size());
|
||||
}
|
||||
}
|
||||
|
||||
URI::URI(const URI &other) :
|
||||
_uri(other._uri ? new uint8_t[other._uri_size] : NULL),
|
||||
_uri_size(other._uri_size)
|
||||
{
|
||||
if (_uri) {
|
||||
memcpy(_uri, other._uri, other._uri_size);
|
||||
}
|
||||
}
|
||||
|
||||
URI::~URI()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue