Skip to content

Commit 30a44c9

Browse files
committed
change jl_get_field_offset to test validity of and return the specified field offset
1 parent 47c26dc commit 30a44c9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/sys.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -631,9 +631,9 @@ JL_DLLEXPORT long jl_SC_CLK_TCK(void)
631631

632632
JL_DLLEXPORT size_t jl_get_field_offset(jl_datatype_t *ty, int field)
633633
{
634-
if (field > jl_datatype_nfields(ty))
634+
if (field > jl_datatype_nfields(ty) || field < 1)
635635
jl_error("This type does not have that many fields");
636-
return jl_field_offset(ty, field);
636+
return jl_field_offset(ty, field-1);
637637
}
638638

639639
JL_DLLEXPORT size_t jl_get_alignment(jl_datatype_t *ty)

0 commit comments

Comments
 (0)