new_buf = V3_Malloc(new_size);
if (new_buf == NULL) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in tmp_realloc in xml\n");
return NULL;
}
vsnprintf(root->err, V3_XML_ERRL, fmt, ap);
va_end(ap);
- PrintError("XML Error: %s\n", root->err);
+ PrintError(VM_NONE, VCORE_NONE, "XML Error: %s\n", root->err);
// free memory
v3_xml_free(&(root->xml));
char * tmp = NULL;
tmp = V3_Malloc((l = strlen(xml->txt)) + len);
+
+ if (!tmp) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml char content\n");
+ return ;
+ }
+
strcpy(tmp, xml->txt);
xml->txt = tmp;
}
static struct v3_xml * v3_xml_new(const char * name) {
struct v3_xml_root * root = (struct v3_xml_root *)V3_Malloc(sizeof(struct v3_xml_root));
+
+ if (!root) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml_new\n");
+ return NULL;
+ }
+
memset(root, 0, sizeof(struct v3_xml_root));
root->xml.name = (char *)name;
}
child = (struct v3_xml *)V3_Malloc(sizeof(struct v3_xml));
+
+ if (!child) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml_add_child\n");
+ return NULL;
+ }
+
memset(child, 0, sizeof(struct v3_xml));
child->name = (char *)name;
((attr_cnt * (2 * sizeof(char *))) +
(2 * sizeof(char *))));
+ if (!attr) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml parse string\n");
+ return NULL;
+ }
+
attr[last_idx] = tmp_realloc(attr[last_idx - 2],
attr_cnt,
(attr_cnt + 1));
+
+ if (!attr[last_idx]) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml parse string\n");
+ return NULL;
+ }
+
} else {
attr = V3_Malloc(4 * sizeof(char *));
+ if (!attr) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml parse string\n");
+ return NULL;
+ }
attr[last_idx] = V3_Malloc(2);
+ if (!attr[last_idx]) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot alloocate in xml parse string\n");
+ return NULL;
+ }
}
attr[attr_idx] = buf; // set attribute name
str_len = strlen(buf);
xml_buf = (char *)V3_Malloc(str_len + 1);
+
+ if (!xml_buf) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml parse\n");
+ return NULL;
+ }
+
strcpy(xml_buf, buf);
return parse_str(xml_buf, str_len);
// first attribute
xml->attr = V3_Malloc(4 * sizeof(char *));
+ if (!xml->attr) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml set attr\n");
+ return NULL;
+ }
+
// empty list of malloced names/vals
xml->attr[1] = strdup("");
+
+ if (!xml->attr[1]) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot strdup in xml set attr\n");
+ return NULL;
+ }
+
} else {
xml->attr = tmp_realloc(xml->attr, l * sizeof(char *), (l + 4) * sizeof(char *));
+
+ if (!xml->attr) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml set attr\n");
+ return NULL;
+ }
}
// set attribute name
strlen(xml->attr[l + 1]),
(c = strlen(xml->attr[l + 1])) + 2);
+
+ if (!xml->attr[l + 3]) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot reallocate in xml set attr\n");
+ return NULL;
+ }
+
// set name/value as not malloced
strcpy(xml->attr[l + 3] + c, " ");
struct v3_xml * o = (xml) ? xml->ordered : NULL;
struct v3_xml_root * root = (struct v3_xml_root *)xml;
size_t len = 0, max = V3_XML_BUFSIZE;
- char *s = strcpy(V3_Malloc(max), "");
+ char *s = V3_Malloc(max);
+
+ if (!s) {
+ PrintError(VM_NONE, VCORE_NONE, "Cannot allocate in xml tostrr\n");
+ return NULL;
+ }
+
+ strcpy(s, "");
if (! xml || ! xml->name) return tmp_realloc(s, max, len + 1);
while (root->xml.parent) root = (struct v3_xml_root *)root->xml.parent; // root tag