Skip to content

Commit

Permalink
usb-ccid: make ccid_write_data_block() cope with null buffers
Browse files Browse the repository at this point in the history
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é <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
  • Loading branch information
philmd authored and Michael Tokarev committed May 7, 2017
1 parent 46bbbec commit 6b1de14
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hw/usb/dev-smartcard-reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 6b1de14

Please sign in to comment.