Skip to content

Commit a4c276d

Browse files
committed
CameraDisplay: don't call getCameraInfoTopic() for empty topic
This would cause an invalid read/write memory access: ros-perception/image_common#148
1 parent 82042f7 commit a4c276d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/rviz/default_plugin/camera_display.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,16 @@ void CameraDisplay::reset()
539539
// we will not receive another message after reset, i.e. the caminfo could not be recovered.
540540
// Thus, we reset caminfo only if unsubscribing.
541541

542-
const std::string caminfo_topic = image_transport::getCameraInfoTopic(topic_property_->getTopicStd());
543-
boost::mutex::scoped_lock lock( caminfo_mutex_ );
544-
if (!current_caminfo_)
545-
setStatus( StatusProperty::Warn, "Camera Info",
546-
"No CameraInfo received on [" + QString::fromStdString( caminfo_topic ) + "].\n"
547-
"Topic may not exist.");
542+
const std::string topic = topic_property_->getTopicStd();
543+
if (!topic.empty())
544+
{
545+
const std::string caminfo_topic = image_transport::getCameraInfoTopic(topic);
546+
boost::mutex::scoped_lock lock( caminfo_mutex_ );
547+
if (!current_caminfo_)
548+
setStatus( StatusProperty::Warn, "Camera Info",
549+
"No CameraInfo received on [" + QString::fromStdString( caminfo_topic ) + "].\n"
550+
"Topic may not exist.");
551+
}
548552
}
549553

550554
} // namespace rviz

0 commit comments

Comments
 (0)