projects
/
platform
/
upstream
/
llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
0cbe2ef
)
[UB] Fix another place where we would pass a null pointer to memcpy.
author
Chandler Carruth
<chandlerc@gmail.com>
Tue, 4 Aug 2015 00:53:01 +0000
(
00:53
+0000)
committer
Chandler Carruth
<chandlerc@gmail.com>
Tue, 4 Aug 2015 00:53:01 +0000
(
00:53
+0000)
This too was found by UBSan. Down to 35 failures for me.
llvm-svn: 243932
llvm/include/llvm/ADT/StringMap.h
patch
|
blob
|
history
diff --git
a/llvm/include/llvm/ADT/StringMap.h
b/llvm/include/llvm/ADT/StringMap.h
index
8721c73
..
9d03856
100644
(file)
--- a/
llvm/include/llvm/ADT/StringMap.h
+++ b/
llvm/include/llvm/ADT/StringMap.h
@@
-158,7
+158,8
@@
public:
// Copy the string information.
char *StrBuffer = const_cast<char*>(NewItem->getKeyData());
- memcpy(StrBuffer, Key.data(), KeyLength);
+ if (KeyLength > 0)
+ memcpy(StrBuffer, Key.data(), KeyLength);
StrBuffer[KeyLength] = 0; // Null terminate for convenience of clients.
return NewItem;
}