Add null terminator to upstream branch string

This commit is contained in:
Kevin Sawicki 2013-03-04 19:10:01 -08:00
parent 673e8c948f
commit 5005aa0c7c

View File

@ -141,9 +141,9 @@ namespace v8_extensions {
const char* shortMergeBranchName;
GetShortBranchName(&shortMergeBranchName, merge);
if (shortMergeBranchName != NULL) {
int shortMergeBranchNameLength = strlen(shortMergeBranchName);
int updateRefLength = strlen(remote) + shortMergeBranchNameLength + 15;
char* upstreamBranch = (char*) malloc(sizeof(char) * updateRefLength);
int updateBranchLength = strlen(remote) + strlen(shortMergeBranchName) + 14;
char* upstreamBranch = (char*) malloc(sizeof(char) * (updateBranchLength + 1));
upstreamBranch[updateBranchLength] = '\0';
sprintf(upstreamBranch, "refs/remotes/%s/%s", remote, shortMergeBranchName);
free((char*)shortMergeBranchName);
*out = upstreamBranch;