Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements to avoids crashes #13615

Merged
merged 5 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/ds/d400/d400-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,17 @@ namespace librealsense
std::vector<std::shared_ptr<platform::uvc_device>> depth_devices;
auto depth_devs_info = filter_by_mi( all_device_infos, 0 );

if ( depth_devs_info.empty() )
for (auto&& info : depth_devs_info) // Filter just mi=0, DEPTH
{
auto depth_uvc_device = get_backend()->create_uvc_device(info);
if (depth_uvc_device)
depth_devices.push_back(depth_uvc_device);
}

if (depth_devs_info.empty() || depth_devices.empty())
{
throw backend_exception("cannot access depth sensor", RS2_EXCEPTION_TYPE_BACKEND);
}
for (auto&& info : depth_devs_info) // Filter just mi=0, DEPTH
depth_devices.push_back( get_backend()->create_uvc_device( info ) );

std::unique_ptr< frame_timestamp_reader > timestamp_reader_backup( new ds_timestamp_reader() );
frame_timestamp_reader* timestamp_reader_from_metadata;
Expand Down
12 changes: 8 additions & 4 deletions src/ds/d500/d500-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,17 @@ namespace librealsense
std::vector<std::shared_ptr<platform::uvc_device>> depth_devices;
auto depth_devs_info = filter_by_mi( all_device_infos, 0 );

if ( depth_devs_info.empty() )
for (auto&& info : depth_devs_info) // Filter just mi=0, DEPTH
{
throw backend_exception("cannot access depth sensor", RS2_EXCEPTION_TYPE_BACKEND);
auto depth_uvc_device = get_backend()->create_uvc_device(info);
if (depth_uvc_device)
depth_devices.push_back(depth_uvc_device);
}

for( auto & info : depth_devs_info ) // Filter just mi=0, DEPTH
depth_devices.push_back( get_backend()->create_uvc_device( info ) );
if (depth_devs_info.empty() || depth_devices.empty())
{
throw backend_exception("cannot access depth sensor", RS2_EXCEPTION_TYPE_BACKEND);
}

std::unique_ptr< frame_timestamp_reader > timestamp_reader_backup( new ds_timestamp_reader() );
std::unique_ptr<frame_timestamp_reader> timestamp_reader_metadata(new ds_timestamp_reader_from_metadata(std::move(timestamp_reader_backup)));
Expand Down
10 changes: 6 additions & 4 deletions src/win/win-helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,14 +491,16 @@ namespace librealsense
}

// Enumerate all imaging devices
for (int member_index = 0; ; ++member_index)
// 0x1000 ia a large enough limit to permit maximum connection, while avoiding infinite loop
for (DWORD member_index = 0; member_index < 0x1000; ++member_index)
{
// Get device information element from the device information set
if (SetupDiEnumDeviceInfo(device_info, member_index, &devInfo) == FALSE)
{
if( GetLastError() == ERROR_NO_MORE_ITEMS )
break; // stop when none left
continue; // silently ignore other errors
DWORD last_error = GetLastError();
if (last_error == ERROR_NO_MORE_ITEMS)
break; // stop when none left
continue; // silently ignore other errors }
}

std::string parent_uid;
Expand Down
Loading