Check for sysevent plugin init calloc failures
authorAndrew Bays <andrew.bays@gmail.com>
Wed, 18 Sep 2019 11:45:48 +0000 (07:45 -0400)
committerAndrew Bays <andrew.bays@gmail.com>
Wed, 18 Sep 2019 11:45:48 +0000 (07:45 -0400)
src/sysevent.c

index aab5141..7f9aa9f 100644 (file)
@@ -924,16 +924,26 @@ static int sysevent_init(void) /* {{{ */
   ring.buffer = (char **)calloc(buffer_length, sizeof(char *));
 
   if (ring.buffer == NULL) {
   ring.buffer = (char **)calloc(buffer_length, sizeof(char *));
 
   if (ring.buffer == NULL) {
-    ERROR("sysevent plugin: sysevent_init calloc failed");
+    ERROR("sysevent plugin: sysevent_init ring buffer calloc failed");
     return -1;
   }
 
   for (int i = 0; i < buffer_length; i++) {
     ring.buffer[i] = calloc(1, listen_buffer_size);
     return -1;
   }
 
   for (int i = 0; i < buffer_length; i++) {
     ring.buffer[i] = calloc(1, listen_buffer_size);
+
+    if (ring.buffer[i] == NULL) {
+      ERROR("sysevent plugin: sysevent_init ring buffer entry calloc failed");
+      return -1;
+    }
   }
 
   ring.timestamp = (cdtime_t *)calloc(buffer_length, sizeof(cdtime_t));
 
   }
 
   ring.timestamp = (cdtime_t *)calloc(buffer_length, sizeof(cdtime_t));
 
+  if (ring.timestamp == NULL) {
+    ERROR("sysevent plugin: sysevent_init ring buffer timestamp calloc failed");
+    return -1;
+  }
+
   if (sock == -1) {
     struct addrinfo hints = {
         .ai_family = AF_UNSPEC,
   if (sock == -1) {
     struct addrinfo hints = {
         .ai_family = AF_UNSPEC,