diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2017-04-07 19:20:13 -0300 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2017-05-07 09:57:51 +0300 |
commit | 6b1de1484ee2f80d5795358ea79e90c3ceb64167 (patch) | |
tree | 8d523f16245945ffc4dce0438cf93a0d98bff49d /hw/usb/dev-smartcard-reader.c | |
parent | 46bbbec2d30c3d791a6d328e5ef861694ff3eafb (diff) |
usb-ccid: make ccid_write_data_block() cope with null buffers
static code analyzer complain:
hw/usb/dev-smartcard-reader.c:816:5: warning: Null pointer passed as an argument to a 'nonnull' parameter
memcpy(p->abData, data, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reported-by: Clang Static Analyzer
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'hw/usb/dev-smartcard-reader.c')
-rw-r--r-- | hw/usb/dev-smartcard-reader.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 757b8b3f5a..49cb1829b5 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -813,7 +813,10 @@ static void ccid_write_data_block(USBCCIDState *s, uint8_t slot, uint8_t seq, if (p->b.bError) { DPRINTF(s, D_VERBOSE, "error %d\n", p->b.bError); } - memcpy(p->abData, data, len); + if (len) { + g_assert_nonnull(data); + memcpy(p->abData, data, len); + } ccid_reset_error_status(s); usb_wakeup(s->bulk, 0); } |