提交 96e25c49 编写于 作者: P Pascal Cuoq 提交者: Kurt Roeckx

Function pop_info() returned a dangling pointer

Signed-off-by: NKurt Roeckx <kurt@roeckx.be>
Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 abf81f1f
...@@ -331,29 +331,31 @@ static unsigned long app_info_hash(const APP_INFO *a) ...@@ -331,29 +331,31 @@ static unsigned long app_info_hash(const APP_INFO *a)
return (ret); return (ret);
} }
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 tmp;
APP_INFO *ret = NULL; APP_INFO *current = NULL;
if (amih != NULL) { if (amih != NULL) {
CRYPTO_THREADID_current(&tmp.threadid); CRYPTO_THREADID_current(&tmp.threadid);
if ((ret = lh_APP_INFO_delete(amih, &tmp)) != NULL) { if ((current = lh_APP_INFO_delete(amih, &tmp)) != NULL) {
APP_INFO *next = ret->next; APP_INFO *next = current->next;
if (next != NULL) { if (next != NULL) {
next->references++; next->references++;
(void)lh_APP_INFO_insert(amih, next); (void)lh_APP_INFO_insert(amih, next);
} }
if (--(ret->references) <= 0) { if (--(current->references) <= 0) {
ret->next = NULL; current->next = NULL;
if (next != NULL) if (next != NULL)
next->references--; next->references--;
OPENSSL_free(ret); OPENSSL_free(current);
} }
return 1;
} }
} }
return (ret); return 0;
} }
int CRYPTO_mem_debug_push(const char *info, const char *file, int line) int CRYPTO_mem_debug_push(const char *info, const char *file, int line)
...@@ -396,7 +398,7 @@ int CRYPTO_mem_debug_pop(void) ...@@ -396,7 +398,7 @@ int CRYPTO_mem_debug_pop(void)
if (mem_check_on()) { if (mem_check_on()) {
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
ret = (pop_info() != NULL); ret = pop_info();
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE); CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
} }
return (ret); return (ret);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册