Skip to content

Commit

Permalink
Fix nullptr dereference issue in UnicodeScriptTokenizeWithOffsetOp.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 571130507
  • Loading branch information
cantonios authored and tf-text-github-robot committed Oct 5, 2023
1 parent 4f6f69c commit 1697b48
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ class UnicodeScriptTokenizeWithOffsetsOp : public OpKernel {
context->allocate_output(#name, TensorShape({name##_size}), \
&name##_tensor)); \
auto name##_data = name##_tensor->flat<dtype>().data(); \
memcpy(name##_data, name.data(), name##_size * sizeof(dtype));
/* For empty outputs, the data pointer might be null. */ \
if (name##_size > 0) { \
memcpy(name##_data, name.data(), name##_size * sizeof(dtype)); \
} \
do { \
} while (false)

DECLARE_ALLOCATE_AND_FILL_OUTPUT_TENSOR(output_values, int32);
DECLARE_ALLOCATE_AND_FILL_OUTPUT_TENSOR(output_values_inner_splits,
Expand Down

0 comments on commit 1697b48

Please sign in to comment.