Merge branch 'jc/daemon'
[gitweb.git] / refs.c
diff --git a/refs.c b/refs.c
index 17cd0cef3c9819d70083554f99d8f09391171db1..5e653141ceb8183cfb7922c3ad89fd1a0110647a 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -29,7 +29,7 @@ const char *resolve_ref(const char *path, unsigned char *sha1, int reading)
                if (lstat(path, &st) < 0) {
                        if (reading || errno != ENOENT)
                                return NULL;
-                       memset(sha1, 0, 20);
+                       hashclr(sha1);
                        return path;
                }
 
@@ -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);
 }