This addresses some instances where out-of-memory would go undetected, leading
to a crash and/or data corruption.
#include <getopt.h>
#include <stdlib.h>
+#include <cgraph/alloc.h>
#include <cgraph/cgraph.h>
#include <cgraph/exit.h>
#include <cgraph/stack.h>
size_t sz = strlen(gname) + 128;
if (sz > bufsz) {
free(buf);
- buf = malloc(sz);
+ buf = gv_alloc(sz);
}
if (*gname == '%') /* anonymous graph */
else {
if (!buf) {
size_t sz = strlen(outfile) + 100; // enough to handle '_<g>_<b>'
- buf = malloc(sz);
+ buf = gv_alloc(sz);
}
if (suffix) {
if (nb < 0)
if (sfx) {
size = sfx - name;
suffix = sfx + 1;
- path = malloc(size + 1);
- strncpy(path, name, size);
- *(path + size) = '\0';
+ path = gv_strndup(name, size);
} else {
path = name;
}