[gitg] Temporary fix for null-bytes in hunk header
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Temporary fix for null-bytes in hunk header
- Date: Fri, 5 Jul 2013 18:24:59 +0000 (UTC)
commit 9962c325b94ccfa375fb57dfcc44db021d5b4230
Author: Jesse van den Kieboom <jessevdk gmail com>
Date: Fri Jul 5 20:24:35 2013 +0200
Temporary fix for null-bytes in hunk header
libgitg/gitg-diff-view-request-diff.vala | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/libgitg/gitg-diff-view-request-diff.vala b/libgitg/gitg-diff-view-request-diff.vala
index 8a0f1e5..8cb214e 100644
--- a/libgitg/gitg-diff-view-request-diff.vala
+++ b/libgitg/gitg-diff-view-request-diff.vala
@@ -255,7 +255,20 @@ namespace Gitg
maxlines = ml;
}
- hunk_cb(builder, state, delta, range, ((string)header).substring(0,
header.length));
+ // There seems to be a bug where sometimes the hunk header
+ // contains null-bytes. As a temporary fix, we scan the
+ // header for the first null byte and truncate it
+ //
+ // see: https://github.com/libgit2/libgit2/issues/1710
+ for (int i = 0; i < header.length; ++i)
+ {
+ if (header[i] == 0)
+ {
+ header.length = i;
+ }
+ }
+
+ hunk_cb(builder, state, delta, range,
((string)header)[0:header.length]);
return 0;
},
@@ -269,7 +282,7 @@ namespace Gitg
{
++numlines;
- line_cb(builder, delta, range, line_type,
((string)content).substring(0, content.length));
+ line_cb(builder, delta, range, line_type,
((string)content)[0:content.length]);
}
return 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]