Made sure that empty surfaces are not attempted to be destroyed in
[sdlgit/SDL_perl.git] / lib / SDL / TTFont.pm
index 5aab81e..d9b6e60 100644 (file)
@@ -69,8 +69,8 @@ sub new {
 
 sub DESTROY {
        my $self = shift;
-       SDL::FreeSurface($self->{-surface});
-       SDL::TTFCloseFont($self->{-font});
+       SDL::FreeSurface($self->{-surface}) if (defined ($self->{-surface}));
+       SDL::TTFCloseFont($self->{-font}) if (defined ($self->{-font}));
 }
 
 sub print {