Add parens around string length

This commit is contained in:
Kevin Sawicki
2013-03-07 08:54:29 -08:00
parent d509195aab
commit 9fe1be7fe0

View File

@@ -106,7 +106,7 @@ namespace v8_extensions {
return;
int shortNameLength = branchNameLength - 11;
char* shortName = (char*) malloc(sizeof(char) * shortNameLength + 1);
char* shortName = (char*) malloc(sizeof(char) * (shortNameLength + 1));
shortName[shortNameLength] = '\0';
strncpy(shortName, &branchName[11], shortNameLength);
*out = shortName;
@@ -122,9 +122,9 @@ namespace v8_extensions {
return;
int shortBranchNameLength = strlen(shortBranchName);
char* remoteKey = (char*) malloc(sizeof(char) * shortBranchNameLength + 15);
char* remoteKey = (char*) malloc(sizeof(char) * (shortBranchNameLength + 15));
sprintf(remoteKey, "branch.%s.remote", shortBranchName);
char* mergeKey = (char*) malloc(sizeof(char) * shortBranchNameLength + 14);
char* mergeKey = (char*) malloc(sizeof(char) * (shortBranchNameLength + 14));
sprintf(mergeKey, "branch.%s.merge", shortBranchName);
free((char*)shortBranchName);