Skip to content

Commit

Permalink
Fix for bad file descriptor error when no cameras are connected
Browse files Browse the repository at this point in the history
  • Loading branch information
karlrees committed Jul 7, 2024
1 parent 24f38ac commit 3694665
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libpktriggercord/src/pslr.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ pslr_handle_t pslr_init( char *model, char *device ) {
for ( i=0; i<driveNum; ++i ) {
pslr_result result = get_drive_info( drives[i], &fd, vendorId, sizeof(vendorId), productId, sizeof(productId));

// If device error, we shouldn't do anything esle with the file descriptor, so skip to next drive
if (result == PSLR_DEVICE_ERROR) {
continue;
}

DPRINT("\tChecking drive: %s %s %s\n", drives[i], vendorId, productId);
if ( find_in_array( valid_vendors, sizeof(valid_vendors)/sizeof(valid_vendors[0]),vendorId) != -1
&& find_in_array( valid_models, sizeof(valid_models)/sizeof(valid_models[0]), productId) != -1 ) {
Expand Down Expand Up @@ -406,7 +411,6 @@ pslr_handle_t pslr_init( char *model, char *device ) {
}
} else {
close_drive( &fd );
free(drives);
continue;
}
}
Expand Down

0 comments on commit 3694665

Please sign in to comment.