Thread

Commits

  1. Avoid low-probability crash on out-of-memory.

  1. Potential null pointer dereference in postgres.c

    Karina Litskevich <litskevichkarina@gmail.com> — 2024-12-05T16:53:59Z

    Hi hackers,
    
    When backporting 66e94448 to older versions it was forgotten to check
    malloc() result. In 16+ versions guc_malloc() is used to allocate
    memory and it checks if the result pointer is NULL, so there is no
    need to check it after guc_malloc(). Versions before 16 have no
    guc_malloc(), and malloc() is used instead, but we have to check if
    return value is NULL.
    
    Please find attached patch for REL_15_STABLE. This should be fixed in
    older versions too.
    
    Best regards,
    Karina Litskevich
    Postgres Professional: http://postgrespro.com/
    
  2. Re: Potential null pointer dereference in postgres.c

    Tom Lane <tgl@sss.pgh.pa.us> — 2024-12-05T17:23:14Z

    Karina Litskevich <litskevichkarina@gmail.com> writes:
    > When backporting 66e94448 to older versions it was forgotten to check
    > malloc() result. In 16+ versions guc_malloc() is used to allocate
    > memory and it checks if the result pointer is NULL, so there is no
    > need to check it after guc_malloc(). Versions before 16 have no
    > guc_malloc(), and malloc() is used instead, but we have to check if
    > return value is NULL.
    
    Yup, you're right.  Thanks for the report!
    
    			regards, tom lane
    
    
    
    
  3. Re: Potential null pointer dereference in postgres.c

    Maxim Orlov <orlovmg@gmail.com> — 2024-12-06T15:52:20Z

    I'm glad you are bringing up this issue. By the way, there are two more
    annoying places in postmaster.c for pg16 and older. See, strdup() also may
    fail if insufficient memory available.
    
    PFA patch for a REL_16_STABLE. It also applies to older versions.
    
    -- 
    Best regards,
    Maxim Orlov.
    
  4. Re: Potential null pointer dereference in postgres.c

    Maxim Orlov <orlovmg@gmail.com> — 2025-01-10T11:08:51Z

    I have to admit I was wrong with previous v2 patch. Sorry.
    Apparently, the chances of committing this very low, but here is the
    correct one.
    
    -- 
    Best regards,
    Maxim Orlov.