diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index c19847e..4f7a64a 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -352,38 +352,40 @@ static unsigned long app_info_hash(const APP_INFO *a)
 
 static IMPLEMENT_LHASH_HASH_FN(app_info, APP_INFO)
 
-static APP_INFO *pop_info(void)
+/* returns 1 if there was an info to pop, 0 if the stack was empty. */
+static int pop_info(void)
 {
     APP_INFO tmp;
-    APP_INFO *ret = NULL;
+    APP_INFO *current = NULL;
 
     if (amih != NULL) {
         CRYPTO_THREADID_current(&tmp.threadid);
-        if ((ret = lh_APP_INFO_delete(amih, &tmp)) != NULL) {
-            APP_INFO *next = ret->next;
+        if ((current = lh_APP_INFO_delete(amih, &tmp)) != NULL) {
+            APP_INFO *next = current->next;
 
             if (next != NULL) {
                 next->references++;
                 (void)lh_APP_INFO_insert(amih, next);
             }
 #ifdef LEVITTE_DEBUG_MEM
-            if (CRYPTO_THREADID_cmp(&ret->threadid, &tmp.threadid)) {
+            if (CRYPTO_THREADID_cmp(&current->threadid, &tmp.threadid)) {
                 fprintf(stderr,
                         "pop_info(): deleted info has other thread ID (%lu) than the current thread (%lu)!!!!\n",
-                        CRYPTO_THREADID_hash(&ret->threadid),
+                        CRYPTO_THREADID_hash(&current->threadid),
                         CRYPTO_THREADID_hash(&tmp.threadid));
                 abort();
             }
 #endif
-            if (--(ret->references) <= 0) {
-                ret->next = NULL;
+            if (--(current->references) <= 0) {
+                current->next = NULL;
                 if (next != NULL)
                     next->references--;
-                OPENSSL_free(ret);
+                OPENSSL_free(current);
             }
+            return 1;
         }
     }
-    return (ret);
+    return 0;
 }
 
 int CRYPTO_push_info_(const char *info, const char *file, int line)
@@ -440,7 +442,7 @@ int CRYPTO_pop_info(void)
                                  * wrong */
         MemCheck_off();         /* obtain MALLOC2 lock */
 
-        ret = (pop_info() != NULL);
+        ret = pop_info();
 
         MemCheck_on();          /* release MALLOC2 lock */
     }
@@ -454,7 +456,7 @@ int CRYPTO_remove_all_info(void)
     if (is_MemCheck_on()) {     /* _must_ be true */
         MemCheck_off();         /* obtain MALLOC2 lock */
 
-        while (pop_info() != NULL)
+        while (pop_info())
             ret++;
 
         MemCheck_on();          /* release MALLOC2 lock */
