Commit 7bc1d59f by zmo@google.com

Fix a memory out-of-bound visit bug.

So len could equal = max_len, and at this point name[len] is out of the range. BUG= TEST= Review URL: https://codereview.appspot.com/7223045 git-svn-id: https://angleproject.googlecode.com/svn/trunk@1803 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 665dcdce
...@@ -334,7 +334,7 @@ void ShGetNameHashingEntry(const ShHandle handle, ...@@ -334,7 +334,7 @@ void ShGetNameHashingEntry(const ShHandle handle,
} }
strncpy(name, it->first.c_str(), len); strncpy(name, it->first.c_str(), len);
// To be on the safe side in case the source is longer than expected. // To be on the safe side in case the source is longer than expected.
name[len] = '\0'; name[len - 1] = '\0';
len = it->second.length() + 1; len = it->second.length() + 1;
max_len = 0; max_len = 0;
...@@ -345,5 +345,5 @@ void ShGetNameHashingEntry(const ShHandle handle, ...@@ -345,5 +345,5 @@ void ShGetNameHashingEntry(const ShHandle handle,
} }
strncpy(hashedName, it->second.c_str(), len); strncpy(hashedName, it->second.c_str(), len);
// To be on the safe side in case the source is longer than expected. // To be on the safe side in case the source is longer than expected.
hashedName[len] = '\0'; hashedName[len - 1] = '\0';
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment