From 6b1de1484ee2f80d5795358ea79e90c3ceb64167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 7 Apr 2017 19:20:13 -0300 Subject: usb-ccid: make ccid_write_data_block() cope with null buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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é Signed-off-by: Michael Tokarev --- hw/usb/dev-smartcard-reader.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'hw/usb') 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); } -- cgit v1.2.3