You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2016/03/10 14:35:19 UTC
[02/12] lucy-clownfish git commit: Fix a couple of leaking exceptions
Fix a couple of leaking exceptions
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/ce0dfbb5
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/ce0dfbb5
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/ce0dfbb5
Branch: refs/heads/master
Commit: ce0dfbb5a77b55ca59f97eb9cdd6a5de7f59ad86
Parents: 5d0a3ef
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Sat Mar 5 17:50:13 2016 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Sat Mar 5 17:51:27 2016 +0100
----------------------------------------------------------------------
compiler/perl/t/401-class.t | 45 ++++++++++++++++++----------------------
compiler/src/CFCCBlock.c | 5 ++++-
compiler/src/CFCClass.c | 14 +++++++++++--
compiler/src/CFCVariable.c | 5 ++++-
4 files changed, 40 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ce0dfbb5/compiler/perl/t/401-class.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/401-class.t b/compiler/perl/t/401-class.t
index f456471..5e0fcba 100644
--- a/compiler/perl/t/401-class.t
+++ b/compiler/perl/t/401-class.t
@@ -51,32 +51,27 @@ my $should_be_foo = Clownfish::CFC::Model::Class->fetch_singleton(
);
is( $$foo, $$should_be_foo, "fetch_singleton" );
-SKIP: {
- skip( 'Exceptions leak', 3 )
- if $ENV{LUCY_VALGRIND};
+eval { Clownfish::CFC::Model::Class->create(%foo_create_args) };
+like( $@, qr/two classes with name/i,
+ "Can't call create for the same class more than once" );
- eval { Clownfish::CFC::Model::Class->create(%foo_create_args) };
- like( $@, qr/two classes with name/i,
- "Can't call create for the same class more than once" );
-
- eval {
- Clownfish::CFC::Model::Class->create(
- parcel => 'Neato',
- class_name => 'Other::Foo',
- );
- };
- like( $@, qr/class name conflict/i,
- "Can't create classes wth the same final component" );
- eval {
- Clownfish::CFC::Model::Class->create(
- parcel => 'Neato',
- class_name => 'Bar',
- nickname => 'Foo',
- );
- };
- like( $@, qr/class nickname conflict/i,
- "Can't create classes wth the same nickname" );
-}
+eval {
+ Clownfish::CFC::Model::Class->create(
+ parcel => 'Neato',
+ class_name => 'Other::Foo',
+ );
+};
+like( $@, qr/class name conflict/i,
+ "Can't create classes wth the same final component" );
+eval {
+ Clownfish::CFC::Model::Class->create(
+ parcel => 'Neato',
+ class_name => 'Bar',
+ nickname => 'Foo',
+ );
+};
+like( $@, qr/class nickname conflict/i,
+ "Can't create classes wth the same nickname" );
my $foo_jr = Clownfish::CFC::Model::Class->create(
parcel => 'Neato',
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ce0dfbb5/compiler/src/CFCCBlock.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCCBlock.c b/compiler/src/CFCCBlock.c
index 0231877..01d0b42 100644
--- a/compiler/src/CFCCBlock.c
+++ b/compiler/src/CFCCBlock.c
@@ -38,7 +38,10 @@ CFCCBlock_new(const char *contents) {
CFCCBlock*
CFCCBlock_init(CFCCBlock *self, const char *contents) {
- CFCUTIL_NULL_CHECK(contents);
+ if (!contents) {
+ CFCBase_decref((CFCBase*)self);
+ CFCUtil_die("contents cannot be NULL");
+ }
self->contents = CFCUtil_strdup(contents);
return self;
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ce0dfbb5/compiler/src/CFCClass.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCClass.c b/compiler/src/CFCClass.c
index 7ed3167..5e1f795 100644
--- a/compiler/src/CFCClass.c
+++ b/compiler/src/CFCClass.c
@@ -310,8 +310,18 @@ CFCClass_do_create(CFCClass *self, struct CFCParcel *parcel,
|| !parcel_source_dir
|| strcmp(class_source_dir, parcel_source_dir) == 0
) {
- // Store in registry.
- S_register(self);
+ char *error;
+
+ CFCUTIL_TRY {
+ // Store in registry.
+ S_register(self);
+ }
+ CFCUTIL_CATCH(error);
+
+ if (error) {
+ CFCBase_decref((CFCBase*)self);
+ CFCUtil_rethrow(error);
+ }
CFCParcel_add_struct_sym(parcel, self->struct_sym);
}
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/ce0dfbb5/compiler/src/CFCVariable.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCVariable.c b/compiler/src/CFCVariable.c
index c2802fc..6636ba6 100644
--- a/compiler/src/CFCVariable.c
+++ b/compiler/src/CFCVariable.c
@@ -59,7 +59,10 @@ CFCVariable*
CFCVariable_init(CFCVariable *self, const char *exposure, const char *name,
struct CFCType *type, int inert) {
// Validate params.
- CFCUTIL_NULL_CHECK(type);
+ if (!type) {
+ CFCBase_decref((CFCBase*)self);
+ CFCUtil_die("type cannot be NULL");
+ }
// Default exposure to "local".
const char *real_exposure = exposure ? exposure : "local";