[dia] meta: don't crash on empty default properties



commit 066054676ab5b7a8099a29811659ae6dab86a820
Author: Hans Breuer <hans breuer org>
Date:   Fri Jul 26 21:19:45 2013 +0200

    meta: don't crash on empty default properties
    
    Some objects have no properties in case of defaults

 lib/propdialogs.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/lib/propdialogs.c b/lib/propdialogs.c
index cbd1890..273e1d1 100644
--- a/lib/propdialogs.c
+++ b/lib/propdialogs.c
@@ -328,10 +328,11 @@ _prop_list_extend_for_meta (GPtrArray *props)
     {NULL}
   };
 
-  Property *p = g_ptr_array_index(props,0);
+  /* Some objects have no properties in case of defaults */
+  Property *p = props->len > 0 ? g_ptr_array_index(props,0) : NULL;
   GPtrArray *pex = prop_list_from_descs(extras,pdtpp_is_visible);
 
-  if (strcmp (p->descr->type, PROP_TYPE_NOTEBOOK_BEGIN) != 0) {
+  if (!p || strcmp (p->descr->type, PROP_TYPE_NOTEBOOK_BEGIN) != 0) {
     int i, olen = props->len;
     /* wrap everything into a first notebook page */
     g_ptr_array_set_size (props, olen + 2);


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