From 34fce8bbbe19608d819991617f8551a1fa1f0e99 Mon Sep 17 00:00:00 2001 From: "jordan@hack_attack" Date: Sat, 1 Oct 2016 17:58:43 -0700 Subject: [PATCH] added ir_init return value, check for malloc, adding subclasses for cdats correctly in parser --- src/apc/ir.c | 2 +- src/apc/irmem.c | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/apc/ir.c b/src/apc/ir.c index d31bc1a..67a6aaf 100644 --- a/src/apc/ir.c +++ b/src/apc/ir.c @@ -98,7 +98,7 @@ push_cdat curr_cdatp->idx = num_cdats; /* Set the cdat as a subclass of the previous cdat */ - + (*cdat_stackp)->class_list[(*cdat_stackp)->num_classes] = curr_cdatp; /* Push the cdat onto the cdat_stack */ *++cdat_stackp = curr_cdatp; diff --git a/src/apc/irmem.c b/src/apc/irmem.c index dc5cede..1e0024f 100644 --- a/src/apc/irmem.c +++ b/src/apc/irmem.c @@ -85,20 +85,26 @@ struct link* link_buf[PTRS_IN_PAGE]; /* The initalization function of the IR. */ -void +int ir_init() { /* Init root cdat and stack */ char root[4] = "root"; - cdat_buf[num_cdats] = (struct cdat*) malloc(sizeof(struct cdat) ); + if( (cdat_buf[num_cdats] = (struct cdat*) malloc(sizeof(struct cdat))) == NULL) + { + perror("malloc root class failed\n"); + return -1; + } cdat_buf[num_cdats]->idx = num_cdats; memmove(cdat_buf[num_cdats]->name, root, 4); cdat_stackp = cdat_stack; *cdat_stackp++ = cdat_buf[num_cdats++]; + return 0; + } void -- 2.18.0