Skip to content

Commit a78c756

Browse files
authored
fix: don't bind atoms that are prefixed with nil as NULL (#258)
This patch changes the comparison from `utf8ncmp` to `utf8cmp` in order to explicitly match on the size of the atom. I noticed a case of inserting an atom of `:nil_safe?` that was cast to `NULL`. I wasn't sure the correct level to add a test, so please let me know the best place and I can get it added.
1 parent 02097c9 commit a78c756

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

c_src/sqlite3_nif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ bind(ErlNifEnv* env, const ERL_NIF_TERM arg, sqlite3_stmt* statement, int index)
430430
}
431431

432432
if (enif_get_atom(env, arg, the_atom, sizeof(the_atom), ERL_NIF_LATIN1)) {
433-
if (0 == utf8ncmp("undefined", the_atom, 9) || 0 == utf8ncmp("nil", the_atom, 3)) {
433+
if (0 == utf8cmp("undefined", the_atom) || 0 == utf8cmp("nil", the_atom)) {
434434
return sqlite3_bind_null(statement, index);
435435
}
436436

0 commit comments

Comments
 (0)