Commit 81af280e authored by Alexey Hohlov's avatar Alexey Hohlov
Browse files

Ликвидация утечек памяти при преобразованих чисел в строку

parent 38fa4707
......@@ -57,14 +57,18 @@ char* inttostr(int val)
*(res--) = '0' + val%10;
val/=10;
}
while (val > 0);
while (val > 0 && res > buff);
return res + 1;
}
char* ftostr(float val)
{
char *string;
string = new char[99];
sprintf(string,"%f",val);
return string;
static const int MAX = 32;
static char buff[MAX] = {0};
char * res = buff;
snprintf(buff, sizeof(buff), "%f", val);
return res;
}
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