Skip to content

Commit 1642a3a

Browse files
ifplusorShannonDing
authored andcommitted
Fixed: return a reference of object which is released in MQMessage::getProperty. (#73)
1 parent 5fc3216 commit 1642a3a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/message/MQMessage.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ const string MQMessage::PROPERTY_TRANSACTION_CHECK_TIMES = "TRANSACTION_CHECK_TI
4848
const string MQMessage::PROPERTY_CHECK_IMMUNITY_TIME_IN_SECONDS = "CHECK_IMMUNITY_TIME_IN_SECONDS";
4949

5050
const string MQMessage::KEY_SEPARATOR = " ";
51+
52+
static const string EMPTY_STRING = "";
53+
5154
//<!************************************************************************
5255
MQMessage::MQMessage() { Init("", "", "", 0, "", true); }
5356

@@ -109,9 +112,9 @@ void MQMessage::setPropertyInternal(const string& name, const string& value) {
109112

110113
const string & MQMessage::getProperty(const string& name) const {
111114
map<string, string>::const_iterator it = m_properties.find(name);
112-
if(it == m_properties.end()){
113-
return "";
114-
}else{
115+
if (it == m_properties.end()) {
116+
return EMPTY_STRING;
117+
} else {
115118
return it->second;
116119
}
117120
}

0 commit comments

Comments
 (0)