Thirdparty: Properly handle error condition in nanosvg
ftell() returns -1 on an error, so it must be a long return type, and we should test for its failure. (found by Coverity)
This commit is contained in:
parent
68985490c6
commit
2becd368d9
|
@ -3669,7 +3669,7 @@ NSVGimage* nsvgParse( char* input, const char* units, float dpi )
|
||||||
|
|
||||||
NSVGimage* nsvgParseFromFile( FILE *fp, const char* units, float dpi )
|
NSVGimage* nsvgParseFromFile( FILE *fp, const char* units, float dpi )
|
||||||
{
|
{
|
||||||
size_t size;
|
long size;
|
||||||
char* data = NULL;
|
char* data = NULL;
|
||||||
NSVGimage* image = NULL;
|
NSVGimage* image = NULL;
|
||||||
|
|
||||||
|
@ -3678,6 +3678,10 @@ NSVGimage* nsvgParseFromFile( FILE *fp, const char* units, float dpi )
|
||||||
|
|
||||||
fseek( fp, 0, SEEK_END );
|
fseek( fp, 0, SEEK_END );
|
||||||
size = ftell( fp );
|
size = ftell( fp );
|
||||||
|
|
||||||
|
if( size < 0 )
|
||||||
|
goto error;
|
||||||
|
|
||||||
fseek( fp, 0, SEEK_SET );
|
fseek( fp, 0, SEEK_SET );
|
||||||
data = (char*) malloc( size + 1 );
|
data = (char*) malloc( size + 1 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue