K2InformaticsGmbH / oranif

Oracle OCI driver using dirty NIF
Apache License 2.0
4 stars 2 forks source link

enif_get_list_cell is not called #89

Closed c-bik closed 5 years ago

c-bik commented 5 years ago

https://github.com/K2InformaticsGmbH/oranif/blob/8a555c02e94cd1fad1eeecf7e7f0e06bceea8c37/c_src/dpiConn_nif.c#L311-L313 https://github.com/K2InformaticsGmbH/oranif/blob/8a555c02e94cd1fad1eeecf7e7f0e06bceea8c37/c_src/dpiStmt_nif.c#L28-L30

If argv[1] is a list enif_is_list(env, argv[1]) will be true and !enif_is_list(env, argv[1]) will be false which reduces the expression effectively to: if(false && !enif_get_list_cell(env, argv[1], &head, &tail))

According to https://en.cppreference.com/w/c/language/eval_order

2) There is a sequence point after evaluation of the first (left) operand and before evaluation of the second (right) operand of the following binary operators: && (logical AND), || (logical OR), and , (comma).

enif_get_list_cell(env, argv[1], &head, &tail) this is never evaluated hence head and tail were never assigned!

c-bik commented 5 years ago

Remove list check all together!

if (!enif_get_list_cell(env, argv[1], &head, &tail)) 
     BADARG_EXCEPTION(1, "nonempty list");

the list check isn't required since enif_get_list_cell checks both... image