Fix allocation formula in llvmjit_expr.c REL_17_STABLE github/REL_17_STABLE
authorMichael Paquier <[email protected]>
Thu, 11 Dec 2025 01:25:46 +0000 (10:25 +0900)
committerMichael Paquier <[email protected]>
Thu, 11 Dec 2025 01:25:46 +0000 (10:25 +0900)
An array of LLVMBasicBlockRef is allocated with the size used for an
element being "LLVMBasicBlockRef *" rather than "LLVMBasicBlockRef".
LLVMBasicBlockRef is a type that refers to a pointer, so this did not
directly cause a problem because both should have the same size, still
it is incorrect.

This issue has been spotted while reviewing a different patch, and
exists since 2a0faed9d702, so backpatch all the way down.

Discussion: https://postgr.es/m/CA+hUKGLngd9cKHtTUuUdEo2eWEgUcZ_EQRbP55MigV2t_zTReg@mail.gmail.com
Backpatch-through: 14

src/backend/jit/llvm/llvmjit_expr.c

index 91785c4ddf1b963ecf39abe0f60b693e6eb02676..4805cdf330a0816692aa1f87400e3f644a41af7d 100644 (file)
@@ -618,8 +618,8 @@ llvm_compile_expr(ExprState *state)
                        LLVMBuildStore(b, l_sbool_const(1), v_resnullp);
 
                        /* create blocks for checking args, one for each */
-                       b_checkargnulls =
-                           palloc(sizeof(LLVMBasicBlockRef *) * op->d.func.nargs);
+                       b_checkargnulls = (LLVMBasicBlockRef *)
+                           palloc(sizeof(LLVMBasicBlockRef) * op->d.func.nargs);
                        for (int argno = 0; argno < op->d.func.nargs; argno++)
                            b_checkargnulls[argno] =
                                l_bb_before_v(b_nonull, "b.%d.isnull.%d", opno,