Don't free the cmd if it's [p]subscribe

If one sent a [p]subscribe command through a websocket, the cmd
struct got freed after the first response was received.  Subscribe
commands generate multiple responses, so this resulted in accessing
already-freed data, and double-freeing.

This patch adds a check to see if it's a subscribe command, and if it
is avoids the freeing.
master
Rob Spanton 13 years ago committed by Nicolas Favre-Felix
parent 5625498ecc
commit 7e3357576a

@ -63,7 +63,10 @@ format_send_reply(struct cmd *cmd, const char *p, size_t sz, const char *content
if(cmd->is_websocket) {
ws_reply(cmd, p, sz);
cmd_free(cmd);
/* If it's a subscribe command, there'll be more responses */
if(!cmd_is_subscribe(cmd))
cmd_free(cmd);
return;
}

Loading…
Cancel
Save