[dia] [scan-build] Dereference of null pointer (maybe)



commit 840f87542b3c055e0fa71f091bf58000d82a6e19
Author: Hans Breuer <hans breuer org>
Date:   Mon Jun 9 10:28:47 2014 +0200

    [scan-build] Dereference of null pointer (maybe)
    
    Protect potential null pointer access with g_return_if_fail().
    Remaining warnings show the unfinished state of focus handling:
    
    textedit.c: In function ‘textedit_end_edit’:
    textedit.c:148:19: warning: unused variable ‘change’ [-Wunused-variable]
       TextEditChange *change;
                       ^
    textedit.c: In function ‘textedit_remove_focus’:
    textedit.c:303:10: warning: unused variable ‘old_focus’ [-Wunused-variable]
       Focus *old_focus = get_active_focus((DiagramData *) diagram);
              ^
    textedit.c: At top level:
    textedit.c:370:1: warning: ‘text_edit_create_change’ defined but not used [-Wunused-function]
     text_edit_create_change(Text *text)
     ^
    textedit.c:394:1: warning: ‘text_edit_update’ defined but not used [-Wunused-function]
     text_edit_update(TextEditChange *change)
     ^
    textedit.c:303:10: warning: Value stored to 'old_focus' during its initialization is never read
      Focus *old_focus = get_active_focus((DiagramData *) diagram);
             ^~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 warning generated.

 app/textedit.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/app/textedit.c b/app/textedit.c
index 9e94d50..c600829 100644
--- a/app/textedit.c
+++ b/app/textedit.c
@@ -172,6 +172,7 @@ textedit_end_edit(DDisplay *ddisp, Focus *focus)
 Focus *
 textedit_move_focus(DDisplay *ddisp, Focus *focus, gboolean forwards)
 {
+  g_return_val_if_fail (ddisp != NULL, NULL);
   if (focus != NULL) {
     textedit_end_edit(ddisp, focus);
   }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]