loader/svg: Return actual decoded size

Returns the actual length of the decoded array.

related issue: https://github.com/thorvg/thorvg/issues/2156
This commit is contained in:
JunsuChoi 2024-04-16 10:48:04 +09:00 committed by Hermet Park
parent a5abc42ed5
commit 4f4ff68896

View file

@ -47,7 +47,6 @@ size_t svgUtilURLDecode(const char *src, char** dst)
if (length == 0) return 0; if (length == 0) return 0;
char* decoded = (char*)malloc(sizeof(char) * length + 1); char* decoded = (char*)malloc(sizeof(char) * length + 1);
decoded[length] = '\0';
char a, b; char a, b;
int idx =0; int idx =0;
@ -64,7 +63,9 @@ size_t svgUtilURLDecode(const char *src, char** dst)
decoded[idx++] = *src++; decoded[idx++] = *src++;
} }
} }
decoded[idx] = '\0';
*dst = decoded; *dst = decoded;
return length + 1; return idx + 1;
} }