libdev.a

C Helper library
Log | Files | Refs | README | LICENSE | git clone https://git.ne02ptzero.me/git/libdev.a

commit b4021e89f7dcdc37fa4370e3046ee4e2334fcc97
parent 5f77ca5c6884e78d6f2fd41bdd94b22e7933bc3a
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Thu, 13 Oct 2016 14:49:53 +0200

Fix(Tests):

Fix an allocation error and a NULL pointer

Diffstat:
Mtests.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tests.c b/tests.c @@ -19,11 +19,13 @@ void register_test(char *group, char *(*fn_test)(void), char *name) { ptr = malloc(sizeof(t_test)); L_ASSERT(ptr); - ptr->group = malloc(strlen(group)); - ptr->name = malloc(strlen(name)); + ptr->group = malloc(strlen(group) + 1); + ptr->name = malloc(strlen(name) + 1); L_ASSERT(ptr->group && ptr->name); memcpy(ptr->group, group, strlen(group)); memcpy(ptr->name, name, strlen(name)); + ptr->name[strlen(name)] = 0; + ptr->group[strlen(group)] = 0; L_ASSERT(ptr->group && ptr->name); ptr->fn_test = fn_test; list_add(tests, ptr, sizeof(t_test));