]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
client: check if memory allocation fails
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 5 Aug 2015 13:47:00 +0000 (15:47 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Wed, 5 Aug 2015 16:07:39 +0000 (18:07 +0200)
Makefile.in
client.c

index 7778db89d8f2d293aece4917524ee40dbc00eab8..c2784c407ff38a28df9f7765c98ce5219931923e 100644 (file)
@@ -44,7 +44,7 @@ OBJS = array.o cmdparse.o conf.o local.o logging.o main.o memory.o mkdirpp.o \
 
 EXTRA_OBJS=@EXTRA_OBJECTS@
 
-CLI_OBJS = client.o nameserv.o getdate.o cmdparse.o \
+CLI_OBJS = client.o cmdparse.o getdate.o memory.o nameserv.o \
            pktlength.o util.o $(HASH_OBJ)
 
 ALL_OBJS = $(OBJS) $(EXTRA_OBJS) $(CLI_OBJS)
index 32092f1bc48d675ee741ee35e1c1ed728ec4edb3..afa9abbce50ca7c8e866b31784c0b038de88b941 100644 (file)
--- a/client.c
+++ b/client.c
@@ -32,6 +32,7 @@
 
 #include "candm.h"
 #include "logging.h"
+#include "memory.h"
 #include "nameserv.h"
 #include "hash.h"
 #include "getdate.h"
@@ -112,7 +113,7 @@ read_line(void)
       line[sizeof(line) - 1] = '\0';
       add_history(cmd);
       /* free the buffer allocated by readline */
-      free(cmd);
+      Free(cmd);
     } else {
       /* simulate the user has entered an empty line */
       *line = '\0';
@@ -1090,7 +1091,7 @@ process_cmd_password(CMD_Request *msg, char *line)
   if (password) {
     for (i = 0; i < password_length; i++)
       password[i] = 0;
-    free(password);
+    Free(password);
     password = NULL;
   }
 
@@ -1108,7 +1109,7 @@ process_cmd_password(CMD_Request *msg, char *line)
   password_length = UTI_DecodePasswordFromText(p);
 
   if (password_length > 0) {
-    password = malloc(password_length);
+    password = Malloc(password_length);
     memcpy(password, p, password_length);
   }
 
@@ -2738,7 +2739,7 @@ process_args(int argc, char **argv, int multi)
     total_length += strlen(argv[i]) + 1;
   }
 
-  line = (char *) malloc((2 + total_length) * sizeof(char));
+  line = (char *) Malloc((2 + total_length) * sizeof(char));
 
   for (i = 0; i < argc; i++) {
     line[0] = '\0';
@@ -2757,7 +2758,7 @@ process_args(int argc, char **argv, int multi)
       break;
   }
 
-  free(line);
+  Free(line);
 
   return ret;
 }
@@ -2884,7 +2885,7 @@ main(int argc, char **argv)
 
   close_io();
 
-  free(password);
+  Free(password);
 
   return !ret;
 }