delwin() and dereferencing issue in viewer, #70
authorMichael Göhler <somebody.here@gmx.de>
Mon, 19 Jan 2015 20:37:58 +0000 (21:37 +0100)
committerMichael Göhler <somebody.here@gmx.de>
Mon, 19 Jan 2015 20:37:58 +0000 (21:37 +0100)
src/viewer.c

index 0e2da58..50646d7 100644 (file)
@@ -93,12 +93,12 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) {
         lc = 0;
         line = slide->line;
 
-        while(line) {
+        while(line && line->text) {
 
-            if (line && line->text && line->text->text)
+            if (line->text->text)
                 lc += url_count_inline(line->text->text);
 
-            if (line && line->text && line->text->text)
+            if (line->text->text)
                 line->length -= url_len_inline(line->text->text);
 
             if(line->length > COLS) {
@@ -415,8 +415,13 @@ int ncurses_display(deck_t *deck, int notrans, int nofade, int invert) {
         url_purge();
     }
 
+    // disable ncurses
     endwin();
 
+    // free ncurses memory
+    delwin(content);
+    delwin(stdscr);
+
     return 0;
 }