Browse Source

Allow add_msg_entry to be called with a null buffer safely

master
Con Kolivas 9 years ago
parent
commit
5cc1812271
  1. 10
      src/stratifier.c

10
src/stratifier.c

@ -454,8 +454,11 @@ struct json_entry {
* to the log outside of lock */ * to the log outside of lock */
static void add_msg_entry(char_entry_t **entries, char **buf) static void add_msg_entry(char_entry_t **entries, char **buf)
{ {
char_entry_t *entry = ckalloc(sizeof(char_entry_t)); char_entry_t *entry;
if (!*buf)
return;
entry = ckalloc(sizeof(char_entry_t));
entry->buf = *buf; entry->buf = *buf;
*buf = NULL; *buf = NULL;
DL_APPEND(*entries, entry); DL_APPEND(*entries, entry);
@ -1337,10 +1340,7 @@ static void _dec_instance_ref(sdata_t *sdata, stratum_instance_t *client, const
* moved due to holding a reference and drop them now. */ * moved due to holding a reference and drop them now. */
if (unlikely(client->dropped && !ref)) { if (unlikely(client->dropped && !ref)) {
__drop_client(sdata, client, true, &msg); __drop_client(sdata, client, true, &msg);
/* Make sure there is a message as throttled users don't add_msg_entry(&entries, &msg);
* generate a message */
if (msg)
add_msg_entry(&entries, &msg);
} }
ck_wunlock(&sdata->instance_lock); ck_wunlock(&sdata->instance_lock);

Loading…
Cancel
Save