Skip to content

Commit

Permalink
hid_netbsd: move null pointer check before dereference
Browse files Browse the repository at this point in the history
Found when trying out smatch
  • Loading branch information
nevun authored and LDVG committed Feb 5, 2024
1 parent 3b8e322 commit c4c7685
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/hid_netbsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ fido_hid_manifest(fido_dev_info_t *devlist, size_t ilen, size_t *olen)
char path[64];
size_t i;

if (devlist == NULL || olen == NULL)
return (FIDO_ERR_INVALID_ARGUMENT);

*olen = 0;

if (ilen == 0)
return (FIDO_OK); /* nothing to do */

if (devlist == NULL || olen == NULL)
return (FIDO_ERR_INVALID_ARGUMENT);

for (i = *olen = 0; i < MAX_UHID && *olen < ilen; i++) {
snprintf(path, sizeof(path), "/dev/uhid%zu", i);
if (copy_info(&devlist[*olen], path) == 0) {
Expand Down

0 comments on commit c4c7685

Please sign in to comment.