Skip to content

MEMORY_LEAK in phpdbg_prompt.c #12675

Closed
Closed

Description

@ellena13

Description

Dynamic memory, referenced by res, is allocated at phpdbg_utils.c:154 :

PHPDBG_API char *phpdbg_resolve_path(const char *path) /* {{{ */
{
char resolved_name[MAXPATHLEN];
if (expand_filepath(path, resolved_name) == NULL) {
return NULL;
}
return strdup(resolved_name);
} /* }}} */

by calling function phpdbg_resolve_path at phpdbg_prompt.c:405 and lost at phpdbg_prompt.c:411 :

char *res = phpdbg_resolve_path(param->str);
size_t res_len = strlen(res);
if ((res_len != PHPDBG_G(exec_len)) || (memcmp(res, PHPDBG_G(exec), res_len) != SUCCESS)) {
if (PHPDBG_G(in_execution)) {
if (phpdbg_ask_user_permission("Do you really want to stop execution to set a new execution context?") == FAILURE) {
return FAILURE;
}

The allocated memory will be lost even if the condition at phpdbg_prompt.c:408 is false.

Found by Linux Verification Center (portal.linuxtesting.ru) with SVACE.

Author E. Bykhanova.

PHP Version

PHP 8.2.3

Operating System

ALT Linux

Activity

  1. changed the title [-]MEMORY_LEAK in /sapi/phpdbg/phpdbg_prompt.c[/-] [+]MEMORY_LEAK in phpdbg_prompt.c[/+] on Nov 15, 2023
  2. self-assigned this
    on Nov 15, 2023
  3. ndossche commented on Nov 15, 2023

    @ndossche
    Member

    There's even a second one in the Execution context not changed path. I'll get to it.
    Thanks for reporting!

  4. added 2 commits that reference this issue on Nov 15, 2023
    465a5fe
    4f1103e
  5. added 2 commits that reference this issue on Nov 15, 2023
    c83632a
    d882c5d
  6. added a commit that references this issue on Nov 23, 2023
    df2af7f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions