From fb8efe03e0da6cfcf5afc6c9f58d0739555ee9b3 Mon Sep 17 00:00:00 2001 From: nick black Date: Mon, 3 Aug 2020 08:46:32 -0400 Subject: [PATCH] cell_strdup(): fix for inline egcs --- include/notcurses/notcurses.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/notcurses/notcurses.h b/include/notcurses/notcurses.h index 30f17e538..9aa8a9a83 100644 --- a/include/notcurses/notcurses.h +++ b/include/notcurses/notcurses.h @@ -664,9 +664,9 @@ static inline char* cell_strdup(const struct ncplane* n, const cell* c){ char* ret; if(cell_simple_p(c)){ - if( (ret = (char*)malloc(2)) ){ // cast is here for C++ clients - ret[0] = c->gcluster; - ret[1] = '\0'; + if( (ret = (char*)malloc(sizeof(c->gcluster) + 1)) ){ // cast is here for C++ clients + memset(ret, 0, sizeof(c->gcluster) + 1); + memcpy(ret, &c->gcluster, sizeof(c->gcluster)); } }else{ ret = strdup(cell_extended_gcluster(n, c));