[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() c
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers |
Date: |
Wed, 22 Mar 2017 17:48:42 -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>
Reviewed-by: Marc-André Lureau <address@hidden>
---
hw/usb/dev-smartcard-reader.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 757b8b3f5a..c38a4e5886 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -799,8 +799,14 @@ static void ccid_write_parameters(USBCCIDState *s,
CCID_Header *recv)
static void ccid_write_data_block(USBCCIDState *s, uint8_t slot, uint8_t seq,
const uint8_t *data, uint32_t len)
{
- CCID_DataBlock *p = ccid_reserve_recv_buf(s, sizeof(*p) + len);
+ CCID_DataBlock *p;
+ if (len == 0) {
+ return;
+ }
+ g_assert(data != NULL);
+
+ p = ccid_reserve_recv_buf(s, sizeof(*p) + len);
if (p == NULL) {
return;
}
--
2.11.0
- [Qemu-devel] [PATCH RESEND 0/3] easy-to-fix clang warnings, Philippe Mathieu-Daudé, 2017/03/22
- [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers,
Philippe Mathieu-Daudé <=
- Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers, Markus Armbruster, 2017/03/23
- Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers, Gerd Hoffmann, 2017/03/23
- Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers, Marc-André Lureau, 2017/03/23
- Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers, Gerd Hoffmann, 2017/03/23
- Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers, Markus Armbruster, 2017/03/23
- Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers, Gerd Hoffmann, 2017/03/23
- Re: [Qemu-devel] [PATCH RESEND 1/3] usb-ccid: make ccid_write_data_block() cope with null buffers, Markus Armbruster, 2017/03/23
[Qemu-devel] [PATCH RESEND 2/3] device_tree: fix compiler warnings (clang 5), Philippe Mathieu-Daudé, 2017/03/22
[Qemu-devel] [PATCH RESEND 3/3] qga: fix compiler warnings (clang 5), Philippe Mathieu-Daudé, 2017/03/22