Skip to content

Commit

Permalink
Check the result of malloc in send_message_to_redis (coturn#1515)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesmz authored Jun 2, 2024
1 parent 0de3bda commit c3d235b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/apps/relay/hiredis_libevent2.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,6 @@ void send_message_to_redis(redis_context_handle rch, const char *command, const

redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int port0, char *pwd, int db) {

struct redisLibeventEvents *e = NULL;
redisAsyncContext *ac = NULL;

char ip[256];
if (ip0 && ip0[0]) {
STRCPY(ip, ip0);
Expand All @@ -230,7 +227,7 @@ redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int
port = port0;
}

ac = redisAsyncConnect(ip, port);
redisAsyncContext *ac = redisAsyncConnect(ip, port);
if (!ac) {
fprintf(stderr, "Error: redisAsyncConnect returned NULL\n");
return NULL;
Expand All @@ -240,7 +237,10 @@ redis_context_handle redisLibeventAttach(struct event_base *base, char *ip0, int
}

/* Create container for context and r/w events */
e = (struct redisLibeventEvents *)malloc(sizeof(struct redisLibeventEvents));
struct redisLibeventEvents *e = (struct redisLibeventEvents *)malloc(sizeof(struct redisLibeventEvents));
if (!e) {
return NULL;
}
memset(e, 0, sizeof(struct redisLibeventEvents));

e->allocated = 1;
Expand Down

0 comments on commit c3d235b

Please sign in to comment.