From 8d59ba8218a2caee93a1c195d21d413c6a5bf569 Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Sat, 26 Jul 2014 00:01:00 +0800 Subject: [PATCH] Do not crash if git diff-tree gives invalid output Signed-off-by: Sup Yut Sum --- src/TortoiseProc/GitDiff.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/TortoiseProc/GitDiff.cpp b/src/TortoiseProc/GitDiff.cpp index 4e110ca59..fde8f0545 100644 --- a/src/TortoiseProc/GitDiff.cpp +++ b/src/TortoiseProc/GitDiff.cpp @@ -264,6 +264,11 @@ int CGitDiff::SubmoduleDiff(const CTGitPath * pPath, const CTGitPath * /*pPath2* return -1; } + if (bytes.size() < 15 + 41 + 40) + { + CMessageBox::Show(NULL, _T("git diff-tree gives invalid output"), _T("TortoiseGit"), MB_OK | MB_ICONERROR); + return -1; + } g_Git.StringAppend(&oldhash, &bytes[15], CP_UTF8, 40); g_Git.StringAppend(&newhash, &bytes[15+41], CP_UTF8, 40); -- 2.11.4.GIT