activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert Strasheim (JIRA)" <j...@apache.org>
Subject [jira] Created: (AMQCPP-43) Crash when getting string property that doesn't exist
Date Fri, 12 Jan 2007 14:14:48 GMT
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

        

Mime
View raw message