提交 ff62bb4d 编写于 作者: D Daniel Gustafsson 提交者: Francisco Guerrero

Fix potential pfree of NULL pointer

If strlen(addr) is zero then based on how get_dest_address() works
addr will be NULL, and pfree() on NULL is not permitted.  Also, we
know that addr will either be a non-empty string or NULL, so we can
just as well test for addr being NULL and avoid a strlen() call.

Fix by only pfreeing when addr is set. (this is in an elog(ERROR..)
context so freeing isn't terribly interesting but it also doesn't
hurt so I'm keeping the current codepath.)
Reviewed-by: NFrancisco Guerrero <aguerrero@pivotal.io>
上级 a8f1381d
......@@ -864,9 +864,11 @@ check_response_status(churl_context *context)
appendStringInfo(&err, "transfer error (%ld): %s",
status, curl_easy_strerror(status));
if (strlen(addr) != 0)
if (addr)
{
appendStringInfo(&err, " from %s", addr);
pfree(addr);
pfree(addr);
}
elog(ERROR, "%s", err.data);
}
elog(DEBUG2, "check_response_status: msg %d done with status OK", i++);
......@@ -912,11 +914,11 @@ check_response_code(churl_context *context)
appendStringInfo(&err, "remote component error (%ld)", response_code);
addr = get_dest_address(context->curl_handle);
if (strlen(addr) != 0)
if (addr)
{
appendStringInfo(&err, " from %s", addr);
pfree(addr);
}
pfree(addr);
if (!handle_special_error(response_code, &err))
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册