Skip to content

Commit

Permalink
Fix memory leak in msg.headers()
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhill committed Sep 28, 2018
1 parent bb16e44 commit cecc139
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions confluent_kafka/src/confluent_kafka.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,13 +1001,15 @@ static int py_header_to_c (rd_kafka_headers_t *rd_headers,
if (cfl_PyBin(_AsStringAndSize(value, (char **)&v,
&vsize)) == -1) {
Py_DECREF(ks);
Py_XDECREF(ks8);
return 0;
}
} else if (cfl_PyUnistr(_Check(value))) {
/* Unicode string, translate to utf-8. */
v = cfl_PyUnistr_AsUTF8(value, &vo8);
if (!v) {
Py_DECREF(ks);
Py_XDECREF(ks8);
return 0;
}
vsize = (Py_ssize_t)strlen(v);
Expand All @@ -1017,6 +1019,8 @@ static int py_header_to_c (rd_kafka_headers_t *rd_headers,
"None, binary, or unicode string, not %s",
((PyTypeObject *)PyObject_Type(value))->
tp_name);
Py_DECREF(ks);
Py_XDECREF(ks8);
return 0;
}
}
Expand All @@ -1027,11 +1031,13 @@ static int py_header_to_c (rd_kafka_headers_t *rd_headers,
"%s",
k, rd_kafka_err2str(err));
Py_DECREF(ks);
Py_XDECREF(ks8);
Py_XDECREF(vo8);
return 0;
}

Py_DECREF(ks);
Py_XDECREF(ks8);
Py_XDECREF(vo8);

return 1;
Expand Down

0 comments on commit cecc139

Please sign in to comment.