summaryrefslogtreecommitdiff
path: root/codegen/valagerrormodule.vala
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2010-10-21 10:33:29 +0200
committerJürg Billeter <j@bitron.ch>2010-10-21 10:33:29 +0200
commit1c89d7f97152ffcfd4b85c64c7343fadc1b22a64 (patch)
tree7f65733d98c54d8eac664fadeca966cdd53af7e1 /codegen/valagerrormodule.vala
parentd78f664ae249124a67e15bc4b6c4ae07e87dffc2 (diff)
downloadvala-1c89d7f97152ffcfd4b85c64c7343fadc1b22a64.tar.gz
codegen: Fix crash when throwing errors from struct constructors
Fixes bug 618461.
Diffstat (limited to 'codegen/valagerrormodule.vala')
-rw-r--r--codegen/valagerrormodule.vala10
1 files changed, 7 insertions, 3 deletions
diff --git a/codegen/valagerrormodule.vala b/codegen/valagerrormodule.vala
index a64b38a9d..b7b4436ad 100644
--- a/codegen/valagerrormodule.vala
+++ b/codegen/valagerrormodule.vala
@@ -102,8 +102,8 @@ public class Vala.GErrorModule : CCodeDelegateModule {
// free local variables
append_local_free (current_symbol, false);
- if (current_method is CreationMethod) {
- var cl = current_method.parent_symbol as Class;
+ if (current_method is CreationMethod && current_method.parent_symbol is Class) {
+ var cl = (Class) current_method.parent_symbol;
var unref_call = get_unref_expression (new CCodeIdentifier ("self"), new ObjectType (cl), null);
ccode.add_expression (unref_call);
ccode.add_return (new CCodeConstant ("NULL"));
@@ -136,7 +136,11 @@ public class Vala.GErrorModule : CCodeDelegateModule {
ccode.add_expression (cclear);
if (current_method is CreationMethod) {
- ccode.add_return (new CCodeConstant ("NULL"));
+ if (current_method.parent_symbol is Struct) {
+ ccode.add_return ();
+ } else {
+ ccode.add_return (new CCodeConstant ("NULL"));
+ }
} else if (current_method != null && current_method.coroutine) {
ccode.add_return (new CCodeConstant ("FALSE"));
} else if (current_return_type != null) {