Number: 1944
Title: Run-time errors using graphviz library
Submitter: Mathias Spoerr
Date: Thu May 6 16:24:34 2010
Subsys: Dot
Version: 2.27
System: x86-Windows-
Severity: minor
When compiling and running the code

#include <graphviz/gvc.h>

int main(int argc, char **argv) { Agraph_t *g; Agnode_t *n, *m; Agedge_t *e; Agsym_t *a; GVC_t *gvc;

/* set up a graphviz context */ gvc = gvContext(); char* args[] = { "dot", "-Tgif", /* gif output */ "-oabc.gif" /* output to file abc.gif */ };

gvParseArgs (gvc, sizeof (args)/sizeof (char*), args);

/* Create a simple digraph */ g = agopen("g", AGDIGRAPH); n = agnode(g, "n"); m = agnode(g, "m"); e = agedge(g, n, m);

/* Set an attribute - in this case one that affects the visible rendering */ agsafeset(n, "color", "red", "");

/* Compute a layout using layout engine from command line args */ gvLayoutJobs(gvc, g);

/* Write the graph according to -T and -o options */ gvRenderJobs(gvc, g);

/* Free layout data */ gvFreeLayout(gvc, g);

/* Free graph structures */ agclose(g);

/* close output file, free context, and return number of errors */ return (gvFreeContext(gvc)); }

I get a seg fault.

When the lines defining args[] are changes to

	char* args[3];
	args[0] = strdup ("dot" );
	args[1] = strdup ("-Tgif" );
	args[2] = strdup ("-oabc.gif" );

the code finishes okay, but then reports a Runtime Check Failure. (See output file).
Output file: b1944.jpg
Owner: arif
Status: *