X-Git-Url: http://git.sourceforge.jp/view?p=tortoisegit%2FTortoiseGitJp.git;a=blobdiff_plain;f=src%2FGit%2Fgittype.h;h=a66f4b66dfac5cb0d57e3c2f2069c9d29e9222cd;hp=2e6474d211073fe3a74e83b926d7bedba790029e;hb=15d631331de487109cb3b4221c81333d36c7cbb4;hpb=8d3c0fc0fb02b293ea14f74af47c5d1900f96afa;ds=sidebyside diff --git a/src/Git/gittype.h b/src/Git/gittype.h index 2e6474d..a66f4b6 100644 --- a/src/Git/gittype.h +++ b/src/Git/gittype.h @@ -40,8 +40,17 @@ public: } int findData(const BYTE* dataToFind, size_t dataSize, int start=0) { - const BYTE* pos=&*begin()+start; - const BYTE* dataEnd=&*end()-(dataSize-1);//Set end one step after last place to search + //Pre checks + if(empty()) + return -1; + if(dataSize==0) + return 0; + if(dataSize>size()-start) + return -1;//Data to find is greater then data to search in. No match + + //Initialize + const BYTE* pos=&*(begin()+start); + const BYTE* dataEnd=&*(begin()+(size()-dataSize) );++dataEnd;//Set end one step after last place to search if(pos>=dataEnd) return -1;//Started over end. Return not found if(dataSize==0) @@ -79,4 +88,5 @@ public: }; typedef std::vector STRING_VECTOR; typedef std::map MAP_HASH_NAME; -typedef CGitByteArray BYTE_VECTOR; \ No newline at end of file +typedef CGitByteArray BYTE_VECTOR; +