From: Rico Tzschichholz Date: Sun, 15 Apr 2018 11:09:12 +0000 (+0200) Subject: vala: Treat floating method-return-type as nullable if error may be thrown X-Git-Tag: 0.41.90~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d6be549d094480e3ec82337bc16df60e99d68366;p=thirdparty%2Fvala.git vala: Treat floating method-return-type as nullable if error may be thrown https://bugzilla.gnome.org/show_bug.cgi?id=795265 --- diff --git a/vala/valamethod.vala b/vala/valamethod.vala index 1adfeabfd..95bcfbe82 100644 --- a/vala/valamethod.vala +++ b/vala/valamethod.vala @@ -704,6 +704,7 @@ public class Vala.Method : Subroutine, Callable { } context.analyzer.current_symbol = this; + return_type.floating_reference = returns_floating_reference; return_type.check (context); var init_attr = get_attribute ("ModuleInit"); diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala index cc6a3fcda..41063ba3e 100644 --- a/vala/valamethodcall.vala +++ b/vala/valamethodcall.vala @@ -504,6 +504,10 @@ public class Vala.MethodCall : Expression { if (m.returns_modified_pointer) { ((MemberAccess) call).inner.lvalue = true; } + // avoid passing possible null to ref_sink_function without checking + if (may_throw && !value_type.nullable && value_type.floating_reference && ret_type is ObjectType) { + value_type.nullable = true; + } var dynamic_sig = m.parent_symbol as DynamicSignal; if (dynamic_sig != null && dynamic_sig.handler != null) {