projects
/
laserbrain_demo
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8d1b171
)
don't crash when calling DataMap::lookup with an empty string
author
John Tsiombikas
<nuclear@mutantstargoat.com>
Sun, 11 Dec 2016 21:28:19 +0000
(23:28 +0200)
committer
John Tsiombikas
<nuclear@mutantstargoat.com>
Sun, 11 Dec 2016 21:28:19 +0000
(23:28 +0200)
src/datamap.cc
patch
|
blob
|
history
diff --git
a/src/datamap.cc
b/src/datamap.cc
index
e466082
..
1f3befe
100644
(file)
--- a/
src/datamap.cc
+++ b/
src/datamap.cc
@@
-93,7
+93,12
@@
int DataMap::lookup(const char *in, char *buf, int bsz) const
char *inbuf = (char*)alloca(strlen(in) + 1);
strcpy(inbuf, in);
char *inbuf = (char*)alloca(strlen(in) + 1);
strcpy(inbuf, in);
- in = clean_line(inbuf);
+ if(!(in = clean_line(inbuf))) {
+ if(buf && bsz > 0) {
+ buf[0] = 0;
+ }
+ return 0;
+ }
// first check the cache
std::map<std::string, std::string>::iterator it = cache.find(in);
// first check the cache
std::map<std::string, std::string>::iterator it = cache.find(in);