Commit ecba0ae8 authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Allow larger buffer in String_Parser

Buffer was dynamically allocated based on first entry of data type.
In case the second entry (e.g. Y) was larger, it was truncated.
parent b39f963e
......@@ -139,8 +139,12 @@ int String_Parser::string(std::string& string, data_obs* data){
os << buffer;
break;}
case 'D':{
// Get number of characters to write
int len = snprintf(c,1,sel.c_str(),data->get_data(1));
// Get number of characters to write:
// Append 50 characters to avoid problems when
// resulting string is larger for second number.
// TODO Easier solution would be to use static buffer length,
// and give warning in case of short buffer.
int len = snprintf(c,1,sel.c_str(),data->get_data(1)) + 50;
char buffer[len+1]="";
// Check if all data or specified data requested
int N; int i;
......@@ -159,7 +163,8 @@ int String_Parser::string(std::string& string, data_obs* data){
break;}
case 'S':{
// Get number of characters to write
int len = snprintf(c,1,sel.c_str(),data->get_supp(1));
// TODO For added 50, see comment above in treatment of 'D'
int len = snprintf(c,1,sel.c_str(),data->get_supp(1)) + 50;
char buffer[len+1]="";
// Check if all data or specified data requested
int N; int i;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment