svg_loader: removing setting the locale

The locale was set while reading the path attr,
which could have caused race conditions between
threads and potentially led to crashes.
Now removed as unnecessary.

@Issue: https://github.com/thorvg/thorvg/issues/1389
This commit is contained in:
Mira Grudzinska 2023-04-22 01:59:32 +02:00 committed by Hermet Park
parent cc75928c23
commit ef93a45d56

View file

@ -52,7 +52,6 @@
#include <cstring> #include <cstring>
#include <math.h> #include <math.h>
#include <clocale>
#include <ctype.h> #include <ctype.h>
#include "tvgSvgLoaderCommon.h" #include "tvgSvgLoaderCommon.h"
#include "tvgSvgPath.h" #include "tvgSvgPath.h"
@ -545,11 +544,6 @@ bool svgPathToTvgPath(const char* svgPath, Array<PathCommand>& cmds, Array<Point
char cmd = 0; char cmd = 0;
bool isQuadratic = false; bool isQuadratic = false;
char* path = (char*)svgPath; char* path = (char*)svgPath;
char* curLocale;
curLocale = setlocale(LC_NUMERIC, NULL);
if (curLocale) curLocale = strdup(curLocale);
setlocale(LC_NUMERIC, "POSIX");
while ((path[0] != '\0')) { while ((path[0] != '\0')) {
path = _nextCommand(path, &cmd, numberArray, &numberCount); path = _nextCommand(path, &cmd, numberArray, &numberCount);
@ -557,8 +551,5 @@ bool svgPathToTvgPath(const char* svgPath, Array<PathCommand>& cmds, Array<Point
if (!_processCommand(&cmds, &pts, cmd, numberArray, numberCount, &cur, &curCtl, &startPoint, &isQuadratic)) break; if (!_processCommand(&cmds, &pts, cmd, numberArray, numberCount, &cur, &curCtl, &startPoint, &isQuadratic)) break;
} }
setlocale(LC_NUMERIC, curLocale);
if (curLocale) free(curLocale);
return true; return true;
} }