mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
loader/svg: Add check to the limits of result of StrToFloat
The string passed to the svg parser is not guaranteed to always be a valid string. Certain strings may have numbers that cannot be converted. Therefore, make sure to check whether the converted value is in the appropriate range before returning. related issue: https://github.com/thorvg/thorvg/issues/2078#issuecomment-2037495121
This commit is contained in:
parent
39e9d6b583
commit
0ebddb4f8f
1 changed files with 3 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
#include "tvgMath.h"
|
#include "tvgMath.h"
|
||||||
|
@ -197,6 +198,8 @@ float strToFloat(const char *nPtr, char **endPtr)
|
||||||
|
|
||||||
success:
|
success:
|
||||||
if (endPtr) *endPtr = (char *)(a);
|
if (endPtr) *endPtr = (char *)(a);
|
||||||
|
if (!std::isfinite(val)) return 0.0f;
|
||||||
|
|
||||||
return minus * val;
|
return minus * val;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|
Loading…
Add table
Reference in a new issue