reading string resulted in garbage when char buffer is not cleared every time. Occured on certain locales
This commit is contained in:
parent
08661558f2
commit
68b02a2348
@ -59,14 +59,14 @@ public:
|
||||
namesInStream.read((char *)&size, sizeof(unsigned));
|
||||
names = new std::vector<std::string>();
|
||||
|
||||
char buf[1024];
|
||||
for(unsigned i = 0; i < size; i++) {
|
||||
unsigned sizeOfString = 0;
|
||||
namesInStream.read((char *)&sizeOfString, sizeof(unsigned));
|
||||
char * buf = new char[1024];
|
||||
memset(buf, 0, 1024*sizeof(char));
|
||||
namesInStream.read(buf, sizeOfString);
|
||||
std::string currentStreetName(buf);
|
||||
names->push_back(currentStreetName);
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
//init complete search engine
|
||||
|
Loading…
Reference in New Issue
Block a user