Skip to content

Commit

Permalink
Fix function parameters with common dependency modified during their …
Browse files Browse the repository at this point in the history
…evaluation (#16620)

This fixes an issue in JNI C++ code. In particular, during a function call, the two passing parameters are evaluated using an index value, but that index is modified during evaluating one of the parameters, leading to out-of-bound access when evaluating the other.

Authors:
  - Nghia Truong (https://github.com/ttnghia)

Approvers:
  - Jason Lowe (https://github.com/jlowe)

URL: #16620
  • Loading branch information
ttnghia authored Aug 21, 2024
1 parent 8ab553c commit 6a2f323
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions java/src/main/native/src/TableJni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1037,9 +1037,9 @@ cudf::io::schema_element read_schema_element(int& index,
// go to the next entry, so recursion can parse it.
index++;
for (int i = 0; i < num_children; i++) {
auto const name = std::string{names.get(index).get()};
child_elems.insert(
std::pair{names.get(index).get(),
cudf::jni::read_schema_element(index, children, names, types, scales)});
std::pair{name, cudf::jni::read_schema_element(index, children, names, types, scales)});
}
return cudf::io::schema_element{d_type, std::move(child_elems)};
} else {
Expand Down Expand Up @@ -1830,9 +1830,9 @@ Java_ai_rapids_cudf_Table_readJSONFromDataSource(JNIEnv* env,
std::map<std::string, cudf::io::schema_element> data_types;
int at = 0;
while (at < n_types.size()) {
auto const name = std::string{n_col_names.get(at).get()};
data_types.insert(std::pair{
n_col_names.get(at).get(),
cudf::jni::read_schema_element(at, n_children, n_col_names, n_types, n_scales)});
name, cudf::jni::read_schema_element(at, n_children, n_col_names, n_types, n_scales)});
}
opts.dtypes(data_types);
} else {
Expand Down Expand Up @@ -1929,9 +1929,9 @@ JNIEXPORT jlong JNICALL Java_ai_rapids_cudf_Table_readJSON(JNIEnv* env,
std::map<std::string, cudf::io::schema_element> data_types;
int at = 0;
while (at < n_types.size()) {
auto const name = std::string{n_col_names.get(at).get()};
data_types.insert(std::pair{
n_col_names.get(at).get(),
cudf::jni::read_schema_element(at, n_children, n_col_names, n_types, n_scales)});
name, cudf::jni::read_schema_element(at, n_children, n_col_names, n_types, n_scales)});
}
opts.dtypes(data_types);
} else {
Expand Down

0 comments on commit 6a2f323

Please sign in to comment.