[PATCH] ecpg: fix missing NULL check in ecpg_store_input

Started by Ilya Gladyshev3 months ago2 messageshackers
Jump to latest
#1Ilya Gladyshev
ilya.gladyshev@linux.dev

Hi all,

This is my first contribution, so please correct me if anything
is wrong.

During OOM, PGTYPESnumeric_to_asc() can return NULL even on valid
inputs, which can lead to a NULL deref in ecpg_store_input():

```
str = PGTYPESnumeric_to_asc(nval, nval->dscale);
slen = strlen(str);
```

This patch adds the NULL check, matching the surrounding code. This is
unlikely to be hit in practice, so it's more of a hardening than
a real fix.

---
Ilya Gladyshev // foxido.dev

Attachments:

t253488_1
0001-ecpg-Fix-NULL-pointer-crash-in-numeric-parameter-bin.patchtext/x-diff; name=0001-ecpg-Fix-NULL-pointer-crash-in-numeric-parameter-bin.patchDownload+6-2
#2Michael Paquier
michael@paquier.xyz
In reply to: Ilya Gladyshev (#1)
Re: [PATCH] ecpg: fix missing NULL check in ecpg_store_input

On Tue, Aug 18, 2026 at 10:58:25AM +0000, Gladyshev Ilya wrote:

This patch adds the NULL check, matching the surrounding code. This is
unlikely to be hit in practice, so it's more of a hardening than
a real fix.

Indeed, nice catch. I doubt that it's worth bothering outside of
HEAD for this class of failures due to the fact that they are unlikely
going to be hit in practice. Will do so.
--
Michael