Commit 677f74e
committed
Avoid memcpy() with a NULL source pointer and count == 0
When memcpy() is called on a pointer, the compiler is entitled to assume
that the pointer is not null, which can lead to optimizing nearby code
in potentially undesirable ways. We still want such optimizations
(gcc's -fdelete-null-pointer-checks) in cases where they're valid.
Related: commit 13bba02.
Backpatch to pg11, where this particular instance appeared.
Reported-by: Ranier Vilela <ranier.vf@gmail.com>
Reported-by: Zhihong Yu <zyu@yugabyte.com>
Discussion: https://postgr.es/m/CAEudQApUndmQkr5fLrCKXQ7+ib44i7S+Kk93pyVThS85PnG3bQ@mail.gmail.com
Discussion: https://postgr.es/m/CALNJ-vSdhwSM5f4tnNn1cdLHvXMVe_S+V3nR5GwNrmCPNB2VtQ@mail.gmail.com1 parent 415dc20 commit 677f74e
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1163 | 1163 | | |
1164 | 1164 | | |
1165 | 1165 | | |
| 1166 | + | |
| 1167 | + | |
1166 | 1168 | | |
1167 | 1169 | | |
1168 | 1170 | | |
1169 | 1171 | | |
1170 | 1172 | | |
1171 | 1173 | | |
1172 | | - | |
| 1174 | + | |
| 1175 | + | |
1173 | 1176 | | |
1174 | | - | |
1175 | 1177 | | |
1176 | 1178 | | |
1177 | 1179 | | |
| |||
0 commit comments