Don't attempt to write an error message to a channel that may have been
closed and freed.

[CID #102150](https://scan8.coverity.com/reports.htm#v22612/p10672/fileInstanceId=3625286&defectInstanceId=1525721&mergedDefectId=102150)
This commit is contained in:
Jack Danger Canty 2015-01-19 12:37:21 -08:00
parent d550eecf70
commit 1a090983f5

View File

@ -442,17 +442,18 @@ static void handle_request(Channel *channel, msgpack_object *request)
if (error.set) { if (error.set) {
// Validation failed, send response with error // Validation failed, send response with error
channel_write(channel, if (channel_write(channel,
serialize_response(channel->id, serialize_response(channel->id,
request_id, request_id,
&error, &error,
NIL, NIL,
&out_buffer)); &out_buffer))) {
char buf[256]; char buf[256];
snprintf(buf, sizeof(buf), snprintf(buf, sizeof(buf),
"Channel %" PRIu64 " sent an invalid message, closing.", "Channel %" PRIu64 " sent an invalid message, closing.",
channel->id); channel->id);
call_set_error(channel, buf); call_set_error(channel, buf);
}
return; return;
} }
@ -619,8 +620,7 @@ static void unsubscribe(Channel *channel, char *event)
free(event_string); free(event_string);
} }
/// Close the channel streams/job. The channel resources will be freed by /// Close the channel streams/job and free the channel resources.
/// free_channel later.
static void close_channel(Channel *channel) static void close_channel(Channel *channel)
{ {
if (channel->closed) { if (channel->closed) {