[tor-commits] [tor/master] Use tor_malloc_zero(x), not tor_calloc(x, sizeof(char))

nickm at torproject.org nickm at torproject.org
Sun Nov 2 17:09:19 UTC 2014


commit a142fc29aff4b47640a1a4f59032e25b7360e847
Author: Nick Mathewson <nickm at torproject.org>
Date:   Sun Nov 2 12:08:51 2014 -0500

    Use tor_malloc_zero(x), not tor_calloc(x,sizeof(char))
    
    (Also, fixes a wide line.)
---
 src/common/util.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/common/util.c b/src/common/util.c
index 7710283..27cc9df 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -3465,8 +3465,9 @@ format_win_cmdline_argument(const char *arg)
     smartlist_add(arg_chars, (void*)&backslash);
 
   /* Allocate space for argument, quotes (if needed), and terminator */
-  formatted_arg = tor_calloc((smartlist_len(arg_chars) + (need_quotes ? 2 : 0) + 1),
-                             sizeof(char));
+  const size_t formatted_arg_len = smartlist_len(arg_chars) +
+    (need_quotes ? 2 : 0) + 1;
+  formatted_arg = tor_malloc_zero(formatted_arg_len);
 
   /* Add leading quote */
   i=0;



More information about the tor-commits mailing list