Merge branch 'jc/daemon'
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index e70ef0ae0fe58671a35b71a55fbf81425ee84581..5e653141ceb8183cfb7922c3ad89fd1a0110647a 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -313,8 +313,8 @@ static struct ref_lock *lock_ref_sha1_basic(const char *path,
        }
        lock->lk = xcalloc(1, sizeof(struct lock_file));
 
-       lock->ref_file = strdup(path);
-       lock->log_file = strdup(git_path("logs/%s", lock->ref_file + plen));
+       lock->ref_file = xstrdup(path);
+       lock->log_file = xstrdup(git_path("logs/%s", lock->ref_file + plen));
        lock->force_write = lstat(lock->ref_file, &st) && errno == ENOENT;
 
        if (safe_create_leading_directories(lock->ref_file))
@@ -348,10 +348,8 @@ void unlock_ref(struct ref_lock *lock)
                if (lock->lk)
                        rollback_lock_file(lock->lk);
        }
-       if (lock->ref_file)
-               free(lock->ref_file);
-       if (lock->log_file)
-               free(lock->log_file);
+       free(lock->ref_file);
+       free(lock->log_file);
        free(lock);
 }