This function was retaining a pointer to memory pointed to by its parameter,
`name`, in the global `suffix`. So it is unsafe to call this with anything
except a long lived string. We can make this more obvious/explicit by inlining
the use of `outfile`, the only parameter it is ever called with.
graphviz_exit(v);
}
-static void split(char *name)
-{
+static void split(void) {
char *sfx = 0;
- sfx = strrchr(name, '.');
+ sfx = strrchr(outfile, '.');
if (sfx) {
suffix = sfx + 1;
- size_t size = (size_t)(sfx - name);
+ size_t size = (size_t)(sfx - outfile);
path = xmalloc(size + 1);
- strncpy(path, name, size);
+ strncpy(path, outfile, size);
*(path + size) = '\0';
} else {
- path = name;
+ path = outfile;
}
}
switch (c) {
case 'o':
outfile = optarg;
- split(outfile);
+ split();
break;
case 'C':
useClusters = 1;