[vala/0.40] codegen: Replace invalid array-length assert with internal error



commit 74ddc0cd74af64742744cc7e6a937a15f3ff467a
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 13be80c3a..4c0679a7e 100644
--- a/codegen/valaccodearraymodule.vala
+++ b/codegen/valaccodearraymodule.vala
@@ -135,7 +135,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]