gfio: prevent multitext crash on invalid update
authorJens Axboe <axboe@kernel.dk>
Mon, 12 Mar 2012 10:05:46 +0000 (11:05 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 12 Mar 2012 10:05:46 +0000 (11:05 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
gfio.c

diff --git a/gfio.c b/gfio.c
index 6a227772800aeda32647b82d034747f9422bddca..7f4782821dedb6c20e22479b019229aad1e5691f 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -263,7 +263,7 @@ static void multitext_set_entry(struct multitext_widget *mt, unsigned int index)
 {
        if (index >= mt->max_text)
                return;
 {
        if (index >= mt->max_text)
                return;
-       if (!mt->text[index])
+       if (!mt->text || !mt->text[index])
                return;
 
        mt->cur_text = index;
                return;
 
        mt->cur_text = index;
@@ -273,6 +273,9 @@ static void multitext_set_entry(struct multitext_widget *mt, unsigned int index)
 static void multitext_update_entry(struct multitext_widget *mt,
                                   unsigned int index, const char *text)
 {
 static void multitext_update_entry(struct multitext_widget *mt,
                                   unsigned int index, const char *text)
 {
+       if (!mt->text)
+               return;
+
        if (mt->text[index])
                free(mt->text[index]);
 
        if (mt->text[index])
                free(mt->text[index]);