Made MainTest#test_open_non_ogg_file pass.
[ruby-vorbistagger.git] / ext / vcedit.c
index 22a8271afabfc84f559eddec87ad1c2042b0b0b1..1aee14c25ed1fcf4cd0b0ba2fb2d53edd903b3fa 100644 (file)
@@ -162,7 +162,9 @@ vcedit_state_unref (vcedit_state *state)
        if (--state->refcount)
                return;
 
-       vcedit_clear_internals (state);
+       if (state->opened)
+               vcedit_clear_internals (state);
+
        vcedit_state_free (state);
 }
 
@@ -301,9 +303,9 @@ vcedit_open (vcedit_state *state)
 
                /* Bail if we don't find data in the first 40 kB */
                if (chunks++ >= 10) {
-                       ret = VCEDIT_ERR_INVAL;
+                       ogg_sync_clear (state->oy);
 
-                       goto err;
+                       return VCEDIT_ERR_INVAL;
                }
        }