Skip to content

Commit

Permalink
Resolves #2624 jansson double referencing (#2634)
Browse files Browse the repository at this point in the history
  • Loading branch information
do-not-set-2fa committed Apr 13, 2021
1 parent e6b5c82 commit 1e99614
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions events/janus_gelfevh.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ static int janus_gelfevh_send(char *message) {
int n = send(sockfd, head, bytesToSend + 12, 0);
if(n < 0) {
JANUS_LOG(LOG_WARN, "Sending UDP message failed: %d (%s)\n", errno, g_strerror(errno));
g_free(rnd);
return -1;
}
offset += bytesToSend;
Expand Down Expand Up @@ -589,25 +590,27 @@ static void *janus_gelfevh_handler(void *data) {
json_t *microtimestamp = json_object_get(event, "timestamp");
if(microtimestamp && json_is_integer(microtimestamp)) {
double created_timestamp = (double)json_integer_value(microtimestamp) / 1000000;
json_object_set(output, "timestamp", json_real(created_timestamp));
json_object_set_new(output, "timestamp", json_real(created_timestamp));
} else {
json_object_set(output, "timestamp", json_real(janus_get_real_time()));
json_object_set_new(output, "timestamp", json_real(janus_get_real_time()));
}
json_object_set(output, "host", json_object_get(event, "emitter"));
json_object_set(output, "version", json_string("1.1"));
json_object_set_new(output, "version", json_string("1.1"));
json_object_set(output, "level", json_object_get(event, "type"));
json_object_set(output, "short_message", json_string(short_message));
json_object_set_new(output, "short_message", json_string(short_message));
json_object_set(output, "full_message", event);

if(janus_gelfevh_send(json_dumps(output, json_format)) < 0) {
JANUS_LOG(LOG_WARN, "Couldn't send event to GELF, reconnect?, or event was null: %s\n",
json_dumps(output, json_format));
char *message = json_dumps(output, json_format);
if(janus_gelfevh_send(message) < 0) {
JANUS_LOG(LOG_WARN, "Couldn't send event to GELF, reconnect?, or event was null: %s\n", message);
}
json_decref(output);
free(message);
output = NULL;

break;
}
json_decref(event);
}
JANUS_LOG(LOG_VERB, "Leaving GELF Event handler thread\n");
return NULL;
Expand Down

0 comments on commit 1e99614

Please sign in to comment.