[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/4] usb-ccid: make ccid_write_data_block() cope
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-devel] [PATCH v2 1/4] usb-ccid: make ccid_write_data_block() cope with null buffers |
Date: |
Fri, 7 Apr 2017 19:20:13 -0300 |
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é <address@hidden>
---
hw/usb/dev-smartcard-reader.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
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);
}
--
2.11.0
- [Qemu-devel] [PATCH v2 0/4] 3 easy-to-fix clang warnings, 1 error code fixed, Philippe Mathieu-Daudé, 2017/04/07
- [Qemu-devel] [PATCH v2 1/4] usb-ccid: make ccid_write_data_block() cope with null buffers,
Philippe Mathieu-Daudé <=
- [Qemu-devel] [PATCH v2 2/4] device_tree: fix compiler warnings (clang 5), Philippe Mathieu-Daudé, 2017/04/07
- [Qemu-devel] [PATCH v2 3/4] qga: fix compiler warnings (clang 5), Philippe Mathieu-Daudé, 2017/04/07
- [Qemu-devel] [PATCH v2 4/4] qga: improve error handling in transfer_memory_block, Philippe Mathieu-Daudé, 2017/04/07
- Re: [Qemu-devel] [PATCH v2 0/4] 3 easy-to-fix clang warnings, 1 error code fixed, Michael Tokarev, 2017/04/23