/**
* In the original file, the formatted data reading did not specify the string with width limitation.
- * To prevent the possible overflow, we replace '%s' with '%31s' here.
+ * To prevent the possible overflow, we replace '%s' with '%31s' and use strtol here
*/
- sscanf(str + 4, "%d%31[%%, \t]%d%31[%%, \t]%d", &r, s1, &g, s2, &b);
+ char* end;
+ r = strtol(str + 4, &end, 10);
+ sscanf(end, "%31[%%, \t]", s1);
+ g = strtol(end + strlen(s1), &end, 10);
+ sscanf(end, "%31[%%, \t]", s2);
+ b = strtol(end + strlen(s2), &end, 10);
+
if (strchr(s1, '%')) {
return NSVG_RGB((r*255)/100,(g*255)/100,(b*255)/100);
} else {