[dia] [scan-build] Dereference of null pointer



commit edaaef463c92080297ae1b21a08cab748c54aacc
Author: Hans Breuer <hans breuer org>
Date:   Sun Aug 18 10:47:06 2013 +0200

    [scan-build] Dereference of null pointer
    
    Access to field 'app_data' results in a dereference of a null pointer
    (loaded from variable 'dia_menu').
    This could happen if an object would implement get_object_menu
    but than return NULL from it.

 app/disp_callbacks.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
---
diff --git a/app/disp_callbacks.c b/app/disp_callbacks.c
index 088420b..ebb5226 100644
--- a/app/disp_callbacks.c
+++ b/app/disp_callbacks.c
@@ -349,6 +349,8 @@ popup_object_menu(DDisplay *ddisp, GdkEventButton *bevent)
   } else {
     dia_menu = (obj->ops->get_object_menu)(obj, &last_clicked_pos);
     num_items = dia_menu ? dia_menu->num_items : 0;
+    if (!dia_menu) /* just to be sure */
+      dia_menu = &empty_menu;
   }
 
   if (dia_menu->app_data == NULL) {


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