don't crash when calling DataMap::lookup with an empty string
[laserbrain_demo] / 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);