[vala/0.46] vala: Prevent possible stack-overflow in Class.is_compact/is_immutable



commit d2448bc96a56d0149fbde043f8b6890ff89fec25
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Feb 19 14:56:37 2020 +0100

    vala: Prevent possible stack-overflow in Class.is_compact/is_immutable
    
    Guard recursive call on base_class in is_compact and is_immutable by
    checking for cyclic class declaration.

 vala/valaclass.vala | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/vala/valaclass.vala b/vala/valaclass.vala
index d61e47a51..42b33dfc3 100644
--- a/vala/valaclass.vala
+++ b/vala/valaclass.vala
@@ -45,7 +45,7 @@ public class Vala.Class : ObjectTypeSymbol {
        public bool is_compact {
                get {
                        if (_is_compact == null) {
-                               if (base_class != null) {
+                               if (base_class != null && !base_class.is_subtype_of (this)) {
                                        _is_compact = base_class.is_compact;
                                } else {
                                        _is_compact = get_attribute ("Compact") != null;
@@ -65,7 +65,7 @@ public class Vala.Class : ObjectTypeSymbol {
        public bool is_immutable {
                get {
                        if (_is_immutable == null) {
-                               if (base_class != null) {
+                               if (base_class != null && !base_class.is_subtype_of (this)) {
                                        _is_immutable = base_class.is_immutable;
                                } else {
                                        _is_immutable = get_attribute ("Immutable") != null;


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