Fix memory management in jsonbot.c

This commit is contained in:
Wilco Baan Hofman 2012-08-05 02:45:04 +02:00
parent bdbc16a566
commit feb524931e

View file

@ -39,12 +39,15 @@ STATUS jsonbot_notify(TALLOC_CTX *mem_ctx, dbi_conn conn, const char *prom, cons
outtext = talloc_asprintf(mem_ctx, "%s %s Event at prom %s: %s: %s: %s -- %s\n",
conf->jsonbot_password, conf->jsonbot_privmsg_to, prom, description, code,
sia_code_str(code), sia_code_desc(code));
NO_MEM_RETURN(outtext);
msglen = (strlen(outtext) + 1) + (16 - ((strlen(outtext) + 1) % 16));
msgbuf = talloc_zero_array(mem_ctx, uint8_t, msglen + 1);
msgbuf_crypted = talloc_array(mem_ctx, uint8_t, msglen + 1);
msgbuf = talloc_zero_array(outtext, uint8_t, msglen + 1);
NO_MEM_RETURN(msgbuf);
msgbuf_crypted = talloc_array(outtext, uint8_t, msglen + 1);
NO_MEM_RETURN(msgbuf_crypted);
memcpy(msgbuf, outtext, strlen(outtext));
@ -70,5 +73,7 @@ STATUS jsonbot_notify(TALLOC_CTX *mem_ctx, dbi_conn conn, const char *prom, cons
return ST_GENERAL_FAILURE;
}
talloc_free(outtext);
return ST_OK;
}