[Bug 851] New: Connecting a null port in C++ lead to segfault

http://bugs.orocos.org/show_bug.cgi?id=851

Summary: Connecting a null port in C++ lead to segfault
Product: Toolchain
Version: 2.3.0
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P3
Component: RTT
AssignedTo: orocos-dev [..] ...
ReportedBy: lambert [dot] willy [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

Hi,

I just had a segfault when connecting 2 ports in C++. In InputPortInterface.cpp
(l74) thus function is :

bool InputPortInterface::connectTo(PortInterface* other, ConnPolicy const&
policy)
{
OutputPortInterface* output = dynamic_cast<OutputPortInterface*>(other);
if (! output) {
log(Error) << "InputPort "<< getName() <<" could not connect to "<<
other->getName() << ": not an Output port." <<endlog();
return false;
}
return output->createConnection(*this, policy);
}

so when you are stupid as me to put something null into "other" the log creates
a segfault.

I think it misses something like this at the beginning :

if (! other) {
log(Error) << "InputPort "<< getName() <<" could not connect to a NULL
port" <<endlog();
return false;
}

It is the same into OutputPortInterface.cpp (l98) and following.

I would have been glad to create a patch but git is not my friend tonigth :(

>