use xmallocz to avoid size arithmetic
[gitweb.git] / config.c
index 86a5eb2571fb282a1d7bad9e6d097b2374b550dc..ba8fd1376587848f0691883e7d1d71ad4d75d599 100644 (file)
--- a/config.c
+++ b/config.c
@@ -1878,7 +1878,7 @@ static int git_config_parse_key_1(const char *key, char **store_key, int *basele
         * Validate the key and while at it, lower case it for matching.
         */
        if (store_key)
-               *store_key = xmalloc(strlen(key) + 1);
+               *store_key = xmallocz(strlen(key));
 
        dot = 0;
        for (i = 0; key[i]; i++) {
@@ -1902,8 +1902,6 @@ static int git_config_parse_key_1(const char *key, char **store_key, int *basele
                if (store_key)
                        (*store_key)[i] = c;
        }
-       if (store_key)
-               (*store_key)[i] = 0;
 
        return 0;