From: Rico Tzschichholz Date: Sun, 18 Apr 2021 19:02:21 +0000 (+0200) Subject: codegen: Apply gconstpointer to gpointer cast to GenericType only X-Git-Tag: 0.50.8~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad76d3fdb83d8c21ab6fe2cf5333b2a73a7e68a7;p=thirdparty%2Fvala.git codegen: Apply gconstpointer to gpointer cast to GenericType only --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 985b005c7..a702d38a5 100644 --- a/codegen/valaccodebasemodule.vala +++ b/codegen/valaccodebasemodule.vala @@ -4735,15 +4735,17 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator { } CCodeExpression cifnull; - if (type.type_symbol != null) { - cifnull = new CCodeConstant ("NULL"); - } else { + if (type is GenericType) { // the value might be non-null even when the dup function is null, // so we may not just use NULL for type parameters // cast from gconstpointer to gpointer as methods in // generic classes may not return gconstpointer cifnull = new CCodeCastExpression (cexpr, get_ccode_name (pointer_type)); + } else if (type.type_symbol != null) { + cifnull = new CCodeConstant ("NULL"); + } else { + cifnull = cexpr; } if (is_ref_function_void (type)) {