[gtk-doc/wip/smcv/qsort-null] scangobj: Don't sort an absence of signals/properties




commit 08d038205939c57eabffbcb042e3d9f0a19444f7
Author: Simon McVittie <smcv debian org>
Date:   Fri Aug 21 15:02:25 2020 +0100

    scangobj: Don't sort an absence of signals/properties
    
    qsort (NULL, 0, ...) is formally considered to be undefined behaviour,
    and is diagnosed as such by the undefined behaviour sanitizer.
    
    Resolves: #125
    Signed-off-by: Simon McVittie <smcv debian org>

 gtkdoc/scangobj.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gtkdoc/scangobj.py b/gtkdoc/scangobj.py
index 7434ec1..003c517 100644
--- a/gtkdoc/scangobj.py
+++ b/gtkdoc/scangobj.py
@@ -182,7 +182,8 @@ output_object_signals (FILE *fp, GType object_type)
     object_class_name = g_type_name (object_type);
 
     signals = g_signal_list_ids (object_type, &n_signals);
-    qsort (signals, n_signals, sizeof (guint), compare_signals);
+    if (n_signals > 0)
+      qsort (signals, n_signals, sizeof (guint), compare_signals);
 
     for (sig = 0; sig < n_signals; sig++) {
        output_object_signal (fp, object_class_name, signals[sig]);
@@ -1095,7 +1096,8 @@ output_object_args (FILE *fp, GType object_type)
   style_prop = FALSE;
 
   while (TRUE) {
-    qsort (properties, n_properties, sizeof (GParamSpec *), compare_param_specs);
+    if (n_properties > 0)
+      qsort (properties, n_properties, sizeof (GParamSpec *), compare_param_specs);
     for (arg = 0; arg < n_properties; arg++) {
       GParamSpec *spec = properties[arg];
       const gchar *nick, *blurb, *dot;


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