]> git.proxmox.com Git - libgit2.git/blobdiff - src/notes.c
notes: Do not assume blob contents are NULL-terminated
[libgit2.git] / src / notes.c
index 046a91614f244c6d3037e375a870cf5f4284ee69..9b0d4d5acfbb7f686f18c8dd0d4df9e529f636cb 100644 (file)
@@ -313,6 +313,7 @@ static int note_new(
        git_blob *blob)
 {
        git_note *note = NULL;
+       git_buf note_contents = GIT_BUF_INIT;
 
        note = (git_note *)git__malloc(sizeof(git_note));
        GITERR_CHECK_ALLOC(note);
@@ -323,11 +324,10 @@ static int note_new(
                git_signature_dup(&note->committer, git_commit_committer(commit)) < 0)
                return -1;
 
-       note->message = git__strdup((char *)git_blob_rawcontent(blob));
-       GITERR_CHECK_ALLOC(note->message);
+       git_buf_put(&note_contents, git_blob_rawcontent(blob), git_blob_rawsize(blob));
+       note->message = git_buf_detach(&note_contents);
 
        *out = note;
-
        return 0;
 }