Skip to content

Commit b8b5331

Browse files
author
Yucheng Low
committed
fixed memory leak in nanomsg conversion
1 parent 9641411 commit b8b5331

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

oss_src/cppipc/common/message_types.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace cppipc {
2020

2121
void call_message::clear() {
2222
if (!zmqbodyused) {
23-
if (!body) free((void*)body);
23+
if (body) free((void*)body);
2424
}
2525
body = NULL;
2626
objectid = 0;
@@ -77,16 +77,14 @@ void call_message::emit(nanosockets::zmq_msg_vector& msg) {
7777
z_body->assign(body, bodylen);
7878
}
7979

80-
// we are giving away the body pointer
81-
body = NULL;
8280
clear();
8381
}
8482

8583

8684

8785
void reply_message::clear() {
8886
if (!zmqbodyused) {
89-
if (!body) free((void*)body);
87+
if (body) free((void*)body);
9088
}
9189
body = NULL;
9290
bodylen = 0;
@@ -137,8 +135,6 @@ void reply_message::emit(nanosockets::zmq_msg_vector& msg) {
137135
z_body->assign(body, bodylen);
138136
}
139137

140-
// we are giving away the body pointer
141-
body = NULL;
142138
clear();
143139
}
144140

0 commit comments

Comments
 (0)