Be paranoid about the values sent to upgrade
The docs aren't entirely clear on the order of calls for upgrades so
this is mostly just in case old_priv ever happens to not be what load
returned in priv.
diff --git a/c_src/jiffy.c b/c_src/jiffy.c
index a764ed0..5d34a9c 100644
--- a/c_src/jiffy.c
+++ b/c_src/jiffy.c
@@ -42,7 +42,8 @@
static int
upgrade(ErlNifEnv* env, void** priv, void** old_priv, ERL_NIF_TERM info)
{
- enif_free(*old_priv);
+ if(*old_priv != NULL)
+ enif_free(*old_priv);
return load(env, priv, info);
}