Skip to content

Commit

Permalink
dialogs.c: Don't crash during refresh when no device is connected
Browse files Browse the repository at this point in the history
active_pid does not get reset when the device is unplugged, but the strings
contained in usb_pids are freed. Make sure to not call strdup() on NULL to
avoid a crash.

Signed-off-by: Lars-Peter Clausen <[email protected]>
  • Loading branch information
larsclausen committed Jan 3, 2017
1 parent 192dd67 commit ceb9252
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ static void refresh_usb()
char *current = NULL;

/* get the active setting (if there is one) */
if(active_pid != -1)
if(active_pid != -1 && usb_pids[active_pid])
current = strdup(usb_pids[active_pid]);

for(i = 0; i < 127 ; i++) {
Expand Down

0 comments on commit ceb9252

Please sign in to comment.