aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/StringMap.h
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2008-02-05 23:34:40 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2008-02-05 23:34:40 +0000
commit73e4c07d0e3aaec6c65f15044baea7c25ba8fda0 (patch)
tree838f5042b9f7f966931e7205757f19eb2cbe2dc7 /include/llvm/ADT/StringMap.h
parent07f307d74154af2be9ae7d1c5a90912aef42f0c6 (diff)
downloadexternal_llvm-73e4c07d0e3aaec6c65f15044baea7c25ba8fda0.zip
external_llvm-73e4c07d0e3aaec6c65f15044baea7c25ba8fda0.tar.gz
external_llvm-73e4c07d0e3aaec6c65f15044baea7c25ba8fda0.tar.bz2
Don't dereference an invalid pointer if string is empty.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46781 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/StringMap.h')
-rw-r--r--include/llvm/ADT/StringMap.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h
index dd040f9..27ea5d3 100644
--- a/include/llvm/ADT/StringMap.h
+++ b/include/llvm/ADT/StringMap.h
@@ -273,7 +273,7 @@ public:
return find(Key, Key + strlen(Key));
}
iterator find(const std::string &Key) {
- const char* key_start = &Key[0];
+ const char* key_start = (Key.empty() ? NULL : &Key[0]);
return find(key_start, key_start + Key.size());
}
@@ -286,7 +286,7 @@ public:
return find(Key, Key + strlen(Key));
}
const_iterator find(const std::string &Key) const {
- const char* key_start = &Key[0];
+ const char* key_start = (Key.empty() ? NULL : &Key[0]);
return find(key_start, key_start + Key.size());
}
@@ -295,7 +295,7 @@ public:
return entry.getValue();
}
ValueTy& operator[](const std::string &Key) {
- const char* key_start = &Key[0];
+ const char* key_start = (Key.empty() ? NULL : &Key[0]);
value_type& entry = GetOrCreateValue(key_start, key_start + Key.size());
return entry.getValue();
}
@@ -307,7 +307,7 @@ public:
return count(Key, Key + strlen(Key));
}
size_type count(const std::string &Key) const {
- const char* key_start = &Key[0];
+ const char* key_start = (Key.empty() ? NULL : &Key[0]);
return count(key_start, key_start + Key.size());
}