Only initialize the heap if setup succeeds
diff --git a/memdbg.py b/memdbg.py
index 04f4bc8..e30b68c 100644
--- a/memdbg.py
+++ b/memdbg.py
@@ -27,7 +27,6 @@
     """, libraries=["crypto"])
 C = _ffi.dlopen(None)
 
-heap = {}
 verbose = False
 
 def log(s):
@@ -77,5 +76,7 @@
 
 if _api.CRYPTO_set_mem_functions(malloc, realloc, free):
     print 'Enabled memory debugging'
+    heap = {}
 else:
     print 'Failed to enable memory debugging'
+    heap = None