Thread (17 messages) flat view 17 messages, 4 authors, 2016-06-15

Re: [PATCH v2 06/10] setup_git_env: use git_pathdup instead of xmalloc + sprintf

From: Duy Nguyen <hidden>
Date: 2016-06-15 23:01:44

Possibly related (same subject, not in this thread)

While it's about malloc..

On Fri, Jun 20, 2014 at 4:28 AM, Jeff King [off-list ref] wrote:
quoted hunk ↗ jump to hunk
diff --git a/environment.c b/environment.c
index 4dac5e9..4de7b81 100644
--- a/environment.c
+++ b/environment.c
@@ -135,15 +135,11 @@ static void setup_git_env(void)
        gitfile = read_gitfile(git_dir);
        git_dir = xstrdup(gitfile ? gitfile : git_dir);
        git_object_dir = getenv(DB_ENVIRONMENT);
-       if (!git_object_dir) {
-               git_object_dir = xmalloc(strlen(git_dir) + 9);
-               sprintf(git_object_dir, "%s/objects", git_dir);
-       }
If DB_ENVIRONMENT is set, we should xstrdup(git_object_dir) because
getenv's return value is not guaranteed persistent. Since you're touch
this area, perhaps do it too (in this, or another patch)?
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help