Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ba48b7

Browse files
committed
notes: Do not assume blob contents are NULL-terminated
1 parent 72d0024 commit 1ba48b7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/notes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ static int note_new(
313313
git_blob *blob)
314314
{
315315
git_note *note = NULL;
316+
git_buf note_contents = GIT_BUF_INIT;
316317

317318
note = (git_note *)git__malloc(sizeof(git_note));
318319
GITERR_CHECK_ALLOC(note);
@@ -323,11 +324,10 @@ static int note_new(
323324
git_signature_dup(&note->committer, git_commit_committer(commit)) < 0)
324325
return -1;
325326

326-
note->message = git__strdup((char *)git_blob_rawcontent(blob));
327-
GITERR_CHECK_ALLOC(note->message);
327+
git_buf_put(&note_contents, git_blob_rawcontent(blob), git_blob_rawsize(blob));
328+
note->message = git_buf_detach(&note_contents);
328329

329330
*out = note;
330-
331331
return 0;
332332
}
333333

0 commit comments

Comments
 (0)