if (type == LF_TEXT) { /* type text */
struct logformat_node *node = calloc(1, sizeof(*node));
- if (!node) {
+ str = calloc(1, end - start + 1);
+ if (unlikely(!node || !str)) {
memprintf(err, "out of memory error");
return 0;
}
- str = calloc(1, end - start + 1);
strncpy(str, start, end - start);
str[end - start] = '\0';
node->arg = str;
BUG_ON(def->flags & LOGGER_FL_RESOLVED);
cpy = malloc(sizeof(*cpy));
-
+ if (unlikely(!cpy))
+ return NULL;
/* copy everything that can be easily copied */
memcpy(cpy, def, sizeof(*cpy));