I’m meeting some misunderstanding with ofxSvg.

i’m on OSX 10.8 with xcode 4

I get that error

DrawerBase::isFluidReady() - No fluid solver
SpreadsPsygnosis_Osx(9056,0xaca57a28) malloc: *** error for object 0xe5b54c: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

on this function, line 837


 * Parse a <polyline> or <polygon> element node.  
 * [http://www.w3.org/TR/SVG11/shapes#PolylineElement](http://www.w3.org/TR/SVG11/shapes#PolylineElement)  
 * [http://www.w3.org/TR/SVG11/shapes#PolygonElement](http://www.w3.org/TR/SVG11/shapes#PolygonElement)  
svgtiny_code svgtiny_parse_poly(Poco::XML::Element *poly,  
		struct svgtiny_parse_state state, bool polygon)  
	char *s, *points;  
	float *p;  
	unsigned int i;  
	svgtiny_parse_paint_attributes(poly, &state);  
	svgtiny_parse_transform_attributes(poly, &state);  
	/* read points attribute */  
	//s = points = (char *) xmlGetProp(poly, (const xmlChar *) "points");  
    s = points = (char *) poly->getAttribute("points").c_str();  
	if (!s) {  
		//state.diagram->error_line = poly->line;  
		state.diagram->error_message =  
				"polyline/polygon: missing points attribute";  
		return svgtiny_SVG_ERROR;  
	/* allocate space for path: it will never have more elements than s */  
	p = (float*) malloc(sizeof p[0] * strlen(s));  
	if (!p) {  
		return svgtiny_OUT_OF_MEMORY;  
	/* parse s and build path */  
	for (i = 0; s[i]; i++)  
		if (s[i] == ',')  
			s[i] = ' ';  
	i = 0;  
	while (*s) {  
		float x, y;  
		int n;  
		if (sscanf(s, "%f %f %n", &x, &y, &n) == 2) {  
			if (i == 0)  
				p[i++] = svgtiny_PATH_MOVE;  
				p[i++] = svgtiny_PATH_LINE;  
			p[i++] = x;  
			p[i++] = y;  
			s += n;  
                } else {  
        if (polygon)  
		p[i++] = svgtiny_PATH_CLOSE;  
	return svgtiny_add_path(p, i, &state);  

something known ? any help ?


Hmm. That means that the call to malloc is failing, which is very weird. Can you provide the SVG that you’re using? Because I don’t think that it’s too likely that there’s no memory to create objects for a polyline in SVG.

I had the same problem recently working with SVG´s.

As Joshua says it may be related to the .svg tag file structure. In my case the .svgs came from a designer using Adobe Illustrator and contained the tag which gave me that problem. This is the difference:

<polygon points="x1,y1 x2,y2"/>  
<path fill="color" d="Mx1,y1 x2,y2z"/>  

With Adobe Illustrator you have to apply the compound path option on every object to get tags on the svg file when exporting it. (Object > Compound Path > Create) Also avoid exporting the .svg’s with backwards compatibility. I´m not sure about other SVG editors. Maybe there´s a better open source option.

I have never worked with ofxSVG before that so at that moment I searched for some info about how to generate compatible svgs for OF but couldn’t find any so I compared OF´s SVG example with the one I wanted to parse. Would be nice to know if there´s some info/specs written about that process somewhere.