[glib] gdbus-codegen: avoid error when wrong interface is provided to --annotate



commit 724c8a18464cd3e2fb3547235cf1f82400bbf91e
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Fri Aug 31 11:41:53 2012 +0200

    gdbus-codegen: avoid error when wrong interface is provided to --annotate
    
    If the interface given cannot be matched, `iface_obj' was left uninitialized and
    the iface_obj == None check would end up crashing:
    
    Traceback (most recent call last):
      File "/usr/bin/gdbus-codegen", line 41, in <module>
        sys.exit(codegen_main.codegen_main())
      File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 175, in codegen_main
        apply_annotations(all_ifaces, opts.annotate)
      File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 146, in apply_annotations
        apply_annotation(iface_list, iface, None, None, None, None, key, value)
      File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 64, in apply_annotation
        if iface_obj == None:
    UnboundLocalError: local variable 'iface_obj' referenced before assignment
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=683088

 gio/gdbus-2.0/codegen/codegen_main.py |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/gio/gdbus-2.0/codegen/codegen_main.py b/gio/gdbus-2.0/codegen/codegen_main.py
index 735cc1f..0fa9e79 100755
--- a/gio/gdbus-2.0/codegen/codegen_main.py
+++ b/gio/gdbus-2.0/codegen/codegen_main.py
@@ -56,6 +56,7 @@ def find_prop(iface, prop):
     return None
 
 def apply_annotation(iface_list, iface, method, signal, prop, arg, key, value):
+    iface_obj = None
     for i in iface_list:
         if i.name == iface:
             iface_obj = i



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