myadm

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

commit 3fa8bcec24d9f5b753671c04005b733e452e8393
parent d4f0b331125426e71a2602c4733cb3b5c042afc1
Author: Claudio Alessi <smoppy@gmail.com>
Date:   Tue,  1 Mar 2016 19:47:45 +0100

Add some check in getitem()

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

diff --git a/core.c b/core.c @@ -357,12 +357,15 @@ text(void) { Item * getitem(void) { - int pos = atoi(stfl_ipool_fromwc(ipool, stfl_get(selview->form, L"pos"))); - int i = 0; Item *item; + int pos, n; + + if(!selview) + return NULL; + pos = atoi(stfl_ipool_fromwc(ipool, stfl_get(selview->form, L"pos"))); - for(item = selview->items; item; item = item->next) - if(i++ == pos) + for(item = selview->items, n = 0; item; item = item->next, ++n) + if(n == pos) break; return item; }