myadm

Simple MySQL client for the terminal
git clone git://git.bitsmanent.org/myadm
Log | Files | Refs | README | LICENSE

commit ac18d379c618efd56d2df49b37050371159dd160
parent 2aac5ffacaac90eafb107033031e1627205b16d7
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Sat, 12 Mar 2016 19:21:20 +0100

Fix cloneitem() and cleanupview().
The choice field was not handled properly.

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

diff --git a/core.c b/core.c @@ -201,7 +201,8 @@ cleanupview(View *v) { cleanupfields(&v->fields); if(v->form) stfl_free(v->form); - free(v->choice); + if(v->choice) + cleanupitems(&v->choice); free(v); } @@ -239,13 +240,14 @@ cloneitem(Item *item) { if(!item) return NULL; ic = ecalloc(1, sizeof(Item)); + ic->lens = ecalloc(1, sizeof(int *)); ic->npieces = item->npieces; ic->flags = item->flags; ic->pieces = ecalloc(1, sizeof(char *)); for(i = 0; i < item->npieces; ++i) { - /* XXX pieces are allocated dynamically, the size is not 64. */ - ic->pieces[i] = ecalloc(64, sizeof(char)); - strncpy(ic->pieces[i], item->pieces[i], 64); + ic->pieces[i] = ecalloc(item->lens[i], sizeof(char)); + ic->lens[i] = item->lens[i]; + strncpy(ic->pieces[i], item->pieces[i], item->lens[i]); } return ic; }