Commit 2070e7a8 authored by THIBAULT Samuel's avatar THIBAULT Samuel

Fix overflow on big traces

parent 4fc1bf30
......@@ -118,8 +118,8 @@ void Error::set(const string kind_of_error, const int priority){
}
void Error::set(const string kind_of_error, const unsigned int line_number, const int priority){
char line[10];
sprintf(line, "%d : ", line_number);
char line[sizeof(line_number)*3+3+1];
snprintf(line, sizeof(line), "%d : ", line_number);
set(line + kind_of_error, priority);
}
......@@ -129,8 +129,8 @@ void Error::set_and_print(const string kind_of_error, const int priority){
}
void Error::set_and_print(const string kind_of_error, const unsigned int line_number, const int priority){
char line[10];
sprintf(line, "%d", line_number);
char line[sizeof(line_number)*3+1];
snprintf(line, sizeof(line), "%d", line_number);
set(kind_of_error + " on line " + line, priority);
print(priority);
}
......@@ -138,8 +138,8 @@ void Error::set_and_print(const string kind_of_error, const unsigned int line_nu
bool Error::set_if(bool condition, const string kind_of_error, const unsigned int line_number, const int priority){
if(condition){
char line[10];
sprintf(line, "%d", line_number);
char line[sizeof(line_number)*3+1];
snprintf(line, sizeof(line), "%d", line_number);
set(kind_of_error + " on line " + line, priority);
return true;
}
......
Markdown is supported
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