On Sat, Mar 4, 2017 at 10:57 PM Philippe Mathieu-Daudé <f4...@amsat.org> wrote:
> 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é <f4...@amsat.org> > Reviewed-by: Marc-André Lureau <marcandre.lur...@redhat.com> > --- > 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 > > > -- Marc-André Lureau