Skip to content
Snippets Groups Projects
Commit 4b801e0c authored by Odilitime's avatar Odilitime
Browse files

fix linux crashes

parent ef115137
No related branches found
No related tags found
No related merge requests found
......@@ -43,14 +43,14 @@ bool CFGFileParser::ParseText() {
// Initial buffer for pass 1. tmp holds the config file (fmr. buffer)
// token holds the actual token. pass1_length to keep track of memory,
// reallocate as needed.
char *tmp, *token;
char *tmp, *token;
size_t pass1_length = 0;
struct slre regex; // final validation before adding to second-pass buffer
// Second pass. All comments and .tags stripped out. Starts off at 512 bytes, increases if necessary.
char* directives = static_cast<char*>(tlsf_malloc(512));
char* tmp2;
token = strtok_r(buffer, "\n", &tmp);
while (tmp != nullptr) {
while (token != nullptr) {
if (token[0] == '#' || token[0] == '.' || token[0] == '\n'){ // Comment, Perl directive, or single <LF> found, skip over
token = strtok_r(nullptr, "\n", &tmp);
}
......@@ -80,14 +80,15 @@ bool CFGFileParser::ParseText() {
}
}
// First pass complete, second pass: break up into single directives and <key, value> pairs
token = strtok_r(directives, "\t", &tmp);
char *newScope;
token = strtok_r(directives, "\t", &newScope);
ntr::fast_string key, value;
while (tmp != nullptr){
while (token != nullptr){
key=strtok_r(token, ":", &tmp2);
value=strtok_r(nullptr, "[]", &tmp2);
// strip ending bracket
cfg->Settings.insert({key,value});
token = strtok_r(nullptr, "\t", &tmp);
token = strtok_r(nullptr, "\t", &newScope);
}
#ifdef DEBUG
std::cout << "Settings stringmap contains, in no particular order:\n";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment