Commit ed46f774 authored by Lorenzo's avatar Lorenzo Committed by user2684
Browse files

Correct Request Class memory allocation (#214)

parent ca8879fe
......@@ -164,12 +164,14 @@ float Timer::getElapsed() {
*/
Request::Request(const char* string) {
char str[10];
char* ptr;
strcpy(str,string);
// copy to working area
strcpy((char*)&_value, string);
// tokenize the string and split function from value
strtok_r(str,",",&ptr);
_function = atoi(str);
strtok_r(_value, ",", &ptr);
// get function code
_function = atoi(_value);
// move user data to working area
strcpy(_value,ptr);
#if DEBUG == 1
Serial.print(F("REQ F="));
......
......@@ -492,7 +492,8 @@ class Request {
private:
NodeManager* _node_manager;
int _function;
char* _value;
// Size of buffer to prevent overrun
char _value[MAX_PAYLOAD+1];
};
/***************************************
......
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