diff --git a/src/ds/ds-motion-common.cpp b/src/ds/ds-motion-common.cpp index 0fc40e4223..29411081c3 100644 --- a/src/ds/ds-motion-common.cpp +++ b/src/ds/ds-motion-common.cpp @@ -173,7 +173,9 @@ namespace librealsense if (p->get_stream_type() == RS2_STREAM_ACCEL || p->get_stream_type() == RS2_STREAM_GYRO) { auto motion = dynamic_cast(p.get()); - assert(motion); + if (!motion) + throw std::runtime_error("Stream profile is not motion stream profile"); + auto st = p->get_stream_type(); motion->set_intrinsics([this, st]() { return get_motion_intrinsics(st); }); } diff --git a/src/fw-logs/fw-logs-parser.cpp b/src/fw-logs/fw-logs-parser.cpp index 1a8228744f..d801603a55 100644 --- a/src/fw-logs/fw-logs-parser.cpp +++ b/src/fw-logs/fw-logs-parser.cpp @@ -27,7 +27,7 @@ namespace librealsense fw_log_data fw_logs_parser::parse_fw_log(const fw_logs_binary_data* fw_log_msg) { - fw_log_data log_data; + fw_log_data log_data = fw_log_data(); if (!fw_log_msg || fw_log_msg->logs_buffer.size() == 0) return log_data; diff --git a/src/gl/align-gl.cpp b/src/gl/align-gl.cpp index 1ce9bcc9ee..e614305e66 100644 --- a/src/gl/align-gl.cpp +++ b/src/gl/align-gl.cpp @@ -62,7 +62,12 @@ void align_gl::align_z_to_other(rs2::video_frame& aligned, auto p = _pc->calculate(depth); auto frame_ref = dynamic_cast((librealsense::frame_interface*)aligned.get()); + if (!frame_ref) + throw std::runtime_error("Frame is not depth frame, cannot cast"); + auto gf = dynamic_cast(frame_ref); + if (!gf) + throw std::runtime_error("Frame is not gpu_addon_interface, cannot output texture"); gf->get_gpu_section().set_size(width, height); diff --git a/src/gl/upload.cpp b/src/gl/upload.cpp index 172f91b45d..2adc97f31c 100644 --- a/src/gl/upload.cpp +++ b/src/gl/upload.cpp @@ -75,8 +75,11 @@ namespace librealsense if (new_f) perform_gl_action([&]() { auto gf = dynamic_cast((frame_interface*)new_f.get()); + if (!gf) + throw std::runtime_error("Frame is not gpu_addon_interface, cannot output texture"); uint32_t output_yuv; + gf->get_gpu_section().output_texture(0, &output_yuv, TEXTYPE_UINT16); glBindTexture(GL_TEXTURE_2D, output_yuv); glTexImage2D(GL_TEXTURE_2D, 0, GL_RG8, width, height, 0, GL_RG, GL_UNSIGNED_BYTE, f.get_data()); diff --git a/src/software-sensor.cpp b/src/software-sensor.cpp index 877a6d7130..d86e15ba5a 100644 --- a/src/software-sensor.cpp +++ b/src/software-sensor.cpp @@ -243,6 +243,10 @@ frame_interface * software_sensor::allocate_new_video_frame( video_stream_profil if( frame ) { auto vid_frame = dynamic_cast< video_frame * >( frame ); + + if (!vid_frame) + throw std::runtime_error("Frame is not video frame"); + vid_frame->assign( profile->get_width(), profile->get_height(), stride, bpp * 8 ); auto sd = dynamic_cast< software_device * >( _owner ); sd->register_extrinsic( *profile );