[
https://issues.apache.org/activemq/browse/AMQCPP-43?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_37914
]
Timothy Bish commented on AMQCPP-43:
------------------------------------
Not sure that patch is what we want to do, the function it modifies is
returning a const char * which one would expect would be NULL if the property
is not set.
Can you include a test case that demonstrates the problem? I'd like to see the
unit tests updated if there's something that we aren't testing for, or
catching. That way when we fix it, then we know by running the unit tests that
its fixed.
> Crash when getting string property that doesn't exist
> -----------------------------------------------------
>
> Key: AMQCPP-43
> URL: https://issues.apache.org/activemq/browse/AMQCPP-43
> Project: ActiveMQ C++ Client
> Issue Type: Bug
> Components: CMS Impl
> Affects Versions: 1.1
> Reporter: Albert Strasheim
> Assigned To: Nathan Mittler
> Priority: Minor
> Fix For: 1.1
>
>
> In the case when one calls getStringProperty for a property that doesn't
> exist, a crash occurs because SimpleProperties returns NULL. I think it
> should return "".
> Test code on Linux:
> {noformat}
> #include <string>
> int main(int argc, char* argv)
> {
> std::string str(0);
> return 0;
> }
> {noformat}
> This dies with the following when run on FC6:
> {noformat}
> terminate called after throwing an instance of 'std::logic_error'
> what(): basic_string::_S_construct NULL not valid
> Aborted
> {noformat}
> Proposed patch:
> {noformat}
> ===================================================================
> --- src/main/activemq/util/SimpleProperties.h (revision 495567)
> +++ src/main/activemq/util/SimpleProperties.h (working copy)
> @@ -55,7 +55,7 @@
> std::map< std::string, std::string >::const_iterator iter =
> properties.find( name );
> if( iter == properties.end() ){
> - return NULL;
> + return "";
> }
> return iter->second.c_str();
> {noformat}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira