}
-static char* _parseNumbersArray(char* str, float* points, int* ptCount)
+static char* _parseNumbersArray(char* str, float* points, int* ptCount, int len)
{
int count = 0;
char* end = nullptr;
str = _skipSpace(str, nullptr);
- while (isdigit(*str) || *str == '-' || *str == '+' || *str == '.') {
+ while ((count < len) && (isdigit(*str) || *str == '-' || *str == '+' || *str == '.')) {
points[count++] = strtof(str, &end);
str = end;
str = _skipSpace(str, nullptr);
*/
static Matrix* _parseTransformationMatrix(const char* value)
{
+ const int POINT_CNT = 8;
+
auto matrix = (Matrix*)malloc(sizeof(Matrix));
if (!matrix) return nullptr;
*matrix = {1, 0, 0, 0, 1, 0, 0, 0, 1};
- float points[8];
+ float points[POINT_CNT];
int ptCount = 0;
char* str = (char*)value;
char* end = str + strlen(str);
str = _skipSpace(str, end);
if (*str != '(') goto error;
++str;
- str = _parseNumbersArray(str, points, &ptCount);
+ str = _parseNumbersArray(str, points, &ptCount, POINT_CNT);
if (*str != ')') goto error;
++str;