From: John Tsiombikas Date: Sun, 11 Dec 2016 21:28:19 +0000 (+0200) Subject: don't crash when calling DataMap::lookup with an empty string X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=commitdiff_plain;h=c38b9bd9f3b1f4efdb0de5a2aabc3bddf76b6aec don't crash when calling DataMap::lookup with an empty string --- diff --git a/src/datamap.cc b/src/datamap.cc index e466082..1f3befe 100644 --- 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); - in = clean_line(inbuf); + if(!(in = clean_line(inbuf))) { + if(buf && bsz > 0) { + buf[0] = 0; + } + return 0; + } // first check the cache std::map::iterator it = cache.find(in);