[vala] Do not check GList/GSList references against NULL



commit 28713010f4de75c724be528907491d93f165874e
Author: Jürg Billeter <j bitron ch>
Date:   Tue Apr 14 20:35:31 2009 +0200

    Do not check GList/GSList references against NULL
    
    NULL is a valid empty GList/GSList. Based on patch by Yu Feng,
    fixes bug 578198.
---
 gobject/valaccodebasemodule.vala |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/gobject/valaccodebasemodule.vala b/gobject/valaccodebasemodule.vala
index 069be00..908b257 100644
--- a/gobject/valaccodebasemodule.vala
+++ b/gobject/valaccodebasemodule.vala
@@ -3764,6 +3764,9 @@ internal class Vala.CCodeBaseModule : CCodeModule {
 			ccheck.add_argument (cexpr);
 		} else if (!non_null) {
 			return null;
+		} else if (t == glist_type || t == gslist_type) {
+			// NULL is empty list
+			return null;
 		} else {
 			var cnonnull = new CCodeBinaryExpression (CCodeBinaryOperator.INEQUALITY, new CCodeIdentifier (var_name), new CCodeConstant ("NULL"));
 			ccheck.add_argument (cnonnull);



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