[vala/staging: 3/5] codegen: Replace invalid array-length assert with internal error



commit 837d593e00d1a3ca8a6f2d13fb1514bed7672965
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Oct 4 14:02:18 2018 +0200

    codegen: Replace invalid array-length assert with internal error
    
    While the test-suite triggers this assert with an invalid test an explicit
    crash is not wanted.

 codegen/valaccodearraymodule.vala | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/codegen/valaccodearraymodule.vala b/codegen/valaccodearraymodule.vala
index cd9377512..32f42545c 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -147,7 +147,10 @@ public class Vala.CCodeArrayModule : CCodeMethodCallModule {
                }
 
                List<CCodeExpression> size = ((GLibValue) value).array_length_cvalues;
-               assert (size != null && size.size >= dim);
+               if (size == null || size.size < dim) {
+                       Report.error (null, "internal error: invalid array_length for given dimension");
+                       return new CCodeInvalidExpression ();
+               }
                return size[dim - 1];
        }
 


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