]> asedeno.scripts.mit.edu Git - git.git/blobdiff - commit.c
Allow fetching references from any namespace
[git.git] / commit.c
index 754d1b8a0b8282fd3d1d6bd8f6ccb21b407504a5..7d78e786e9a6a6a3566cb7aa6555a815d79f9e4b 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -640,7 +640,9 @@ static char *get_header(const struct commit *commit, const char *key)
                        next = NULL;
                } else
                        next = eol + 1;
-               if (!strncmp(line, key, key_len) && line[key_len] == ' ') {
+               if (eol - line > key_len &&
+                   !strncmp(line, key, key_len) &&
+                   line[key_len] == ' ') {
                        int len = eol - line - key_len;
                        char *ret = xmalloc(len);
                        memcpy(ret, line + key_len + 1, len - 1);
@@ -720,14 +722,6 @@ static char *logmsg_reencode(const struct commit *commit,
        return out;
 }
 
-static char *xstrndup(const char *text, int len)
-{
-       char *result = xmalloc(len + 1);
-       memcpy(result, text, len);
-       result[len] = '\0';
-       return result;
-}
-
 static void fill_person(struct interp *table, const char *msg, int len)
 {
        int start, end, tz = 0;