Skip to content

Commit

Permalink
Fix problem related to snprintf call
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonylouisbsb committed Apr 29, 2021
1 parent 8beeb4b commit 4f19f8c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cpp/src/gandiva/precompiled/string_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1545,13 +1545,14 @@ const char* to_hex_binary(gdv_int64 context, const char* text, gdv_int32 text_le

gdv_uint32 ret_index = 0;
gdv_uint32 max_len = static_cast<gdv_uint32>(text_len) * 2;
gdv_uint32 max_char_to_write = 4;

for (gdv_int32 i = 0; i < text_len; i++) {
DCHECK(ret_index >= 0 && ret_index < max_len);

gdv_int32 ch = static_cast<gdv_int32>(text[i]) & 0xFF;

ret_index += snprintf(ret + ret_index, 4, "%02X", ch);
ret_index += snprintf(ret + ret_index, max_char_to_write, "%02X", ch);
}

*out_len = static_cast<gdv_int32>(ret_index);
Expand Down

0 comments on commit 4f19f8c

Please sign in to comment.