Skip to content

Named-bind preparation leaks Ivyresult objects on early returns #1555

Closed

Description

@Aias00

Problem

Ivyreplacenamebindtoposition() and Ivyreplacenamebindtoposition2() allocate an Ivyresult through Ivyexec(), but several return paths do not release it with Ivyclear().

Affected paths in src/interfaces/libpq/ivy-exec.c include:

  • the PGRES_TUPLES_OK failure path in both helpers;
  • the successful early return when stmtHandle->namebind == NULL in Ivyreplacenamebindtoposition().

Because Ivyexec() allocates both the Ivyresult wrapper and an underlying PGresult, repeated prepares/executions on these paths leak client memory.

Expected behavior

Every non-NULL result returned by Ivyexec() should be passed to Ivyclear() before the helper returns, on both success and error paths.

Suggested fix

Add cleanup at the affected returns while preserving the existing return values and error messages. Exercise the prepare/execute paths repeatedly under a leak detector or sanitizer.

Activity

  1. jiaoshuntian commented on Aug 12, 2026

    @jiaoshuntian
    Collaborator

    Thank you for reporting this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions