ros-simulation/gazebo_ros_pkgs — pull request #120 by meyerj (2013-09-25 13:06:55+00:00)
Title: Segfaults in camera gazebo plugins due to uninitialized shared pointers

The new shared pointer members introduced in bd078a095da8723347a26fbb007c64bbf49dbb22 (`image_connect_count_`, `image_connect_count_lock_` and `was_active_`) have not properly been initialized in most camera plugins except gazebo_ros_camera.cpp and gazebo_ros_multicamera.cpp. Gazebo therefore segfaults when someone connects to an image subscriber.

cb950af9410e80b833dc5749eac6fbeb900b4cbd added initialization of `image_connect_count_` in the openni plugin, but the other two pointers have still been left uninitialized. The pointers must be initialized before `GazeboRosCameraUtils::LoadThread()` is executed, as they are dereferenced in `GazeboRosCameraUtils::ImageConnect()`.

Additionally in the multi camera plugin the shared pointers have been constructed from pointers to member variables, which is forbidden as the shared_ptr cannot take ownership of this pointer.

I only tested this patch with the gazebo_ros_camera and gazebo_ros_openni_kinect plugins!