don't crash when calling DataMap::lookup with an empty string
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 11 Dec 2016 21:28:19 +0000 (23:28 +0200)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Sun, 11 Dec 2016 21:28:19 +0000 (23:28 +0200)
src/datamap.cc

index e466082..1f3befe 100644 (file)
@@ -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<std::string, std::string>::iterator it = cache.find(in);