Skip to content

Commit efdf3eb

Browse files
committed
Change Field to Store_field
The previous version of the code was using the `Field` macro after an allocation (`caml_copy_string`), in case of a bad timing, this could lead to a hard to debug memory corruption.
1 parent b52cbec commit efdf3eb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/postgresql_stubs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ CAMLprim value PQconndefaults_stub(value __unused v_unit)
315315
for (j = 0; j < 7; j++) Field(v_el, j) = v_None;
316316
Store_field(v_res, i, v_el);
317317
v_field = caml_copy_string(p->keyword);
318-
Field(v_el, 0) = v_field;
318+
Store_field(v_el, 0, v_field);
319319
if (p->envvar) {
320320
v_field = make_some(caml_copy_string(p->envvar));
321321
caml_modify(&Field(v_el, 1), v_field);

0 commit comments

Comments
 (0)