Skip to content

Commit

Permalink
CON-200: Fix double free segfault (#79)
Browse files Browse the repository at this point in the history
* CON-200: Fix double free segfault

* Update test/python/test_rticonnextdds_connector.py

Co-authored-by: Alex Campos <alejandro@rti.com>

Co-authored-by: Sam Raeburn <sam@rti.com>
Co-authored-by: Alex Campos <alejandro@rti.com>
  • Loading branch information
3 people authored Jun 7, 2021
1 parent 8d2110e commit 9ffde89
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rticonnextdds_connector/rticonnextdds_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def __init__(self): # pylint: disable=too-many-statements
self.new.argtypes = [ctypes.c_char_p, ctypes.c_char_p, ctypes.c_void_p]

self.delete = self.library.RTI_Connector_delete
self.delete.restype = ctypes.c_void_p
self.delete.restype = None
self.delete.argtypes = [ctypes.c_void_p]

self.get_writer = self.library.RTI_Connector_get_datawriter
Expand Down Expand Up @@ -1255,8 +1255,8 @@ def __init__(self, config_name, url):

def close(self):
"""Frees all the resources created by this Connector instance"""

connector_binding.delete(self.native)
self.native = 0

# Deprecated: use close()
# pylint: disable=missing-docstring
Expand Down
13 changes: 13 additions & 0 deletions test/python/test_rticonnextdds_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,16 @@ def test_connector_creation_with_participant_qos(self):
config_name=participant_profile,
url=xml_path) as connector:
assert connector is not None

def test_connector_double_deletion(self):
"""Verify CON-200, that Connector does not segfault on double deletion"""
participant_profile = "MyParticipantLibrary::ConnectorWithParticipantQos"
xml_path = os.path.join(os.path.dirname(
os.path.realpath(__file__)),
"../xml/TestConnector.xml")
with rti.open_connector(
config_name=participant_profile,
url=xml_path) as connector:
assert connector is not None
connector.close()
# connector.close() will be called again here due to the with clause

0 comments on commit 9ffde89

Please sign in to comment.