From 1d6594a4913ee02c25e352391ed0a1d353a3a7de Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Sat, 28 Apr 2012 06:31:16 -0400 Subject: [PATCH] Fixed all invalid mmeory accesses --- asm.c | 4 ---- main.c | 2 +- util.c | 12 +++++------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/asm.c b/asm.c index 71a8fa3..573da33 100644 --- a/asm.c +++ b/asm.c @@ -161,10 +161,6 @@ static inline bool asm_parse_func(const char *skip, size_t line, asm_state *stat mem_d(name); return false; } - /* reassign name */ - mem_d(name); - name = util_strchp(name, strchr(name, ',')); - /* * Now add the following items to the code system: * function diff --git a/main.c b/main.c index 475053e..67e0b0c 100644 --- a/main.c +++ b/main.c @@ -155,7 +155,7 @@ int main(int argc, char **argv) { for (itr = 0; itr < items_elements; itr++) mem_d(items_data[itr].name); mem_d(items_data); - + util_meminfo(); return 0; } diff --git a/util.c b/util.c index 95736e1..7cf7812 100644 --- a/util.c +++ b/util.c @@ -126,14 +126,12 @@ char *util_strrq(const char *s) { char *util_strchp(const char *s, const char *e) { if (!s || !e) return NULL; + + const char *c = s; + while (c != e) + c++; - size_t m = 0; - char *c = util_strdup(s); - while (s != e) - s++,c++,m++; - - *c = '\0'; - return c-m; + return util_strdup(s); } /* -- 2.39.2