ViniciusSouzaRoque commented on code in PR #12716:
URL: https://github.com/apache/arrow/pull/12716#discussion_r850628289


##########
cpp/src/gandiva/precompiled/string_ops.cc:
##########
@@ -2815,45 +2814,71 @@ const char* soundex_utf8(gdv_int64 ctx, const char* in, 
gdv_int32 in_len,
   }
 
   // The soundex code is composed by one letter and three numbers
+  char* soundex = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(ctx, 
in_len));
   char* ret = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(ctx, 4));
-  if (ret == nullptr) {
+
+  if (soundex == nullptr || ret == nullptr) {
     gdv_fn_context_set_error_msg(ctx, "Could not allocate memory for output 
string");
     *out_len = 0;
     return "";
   }
 
   int si = 1;
+  int ret_len = 1;
   unsigned char c;
 
   int start_idx = 0;
   for (int i = 0; i < in_len; ++i) {
     if (isalpha(in[i]) > 0) {
+      // Retain the first letter
       ret[0] = toupper(in[i]);
       start_idx = i + 1;
       break;
     }
   }
 
-  for (int i = start_idx, l = in_len; i < l; i++) {
+  // If ret[0] is not initialised, return one exception
+  if (start_idx == 0) {

Review Comment:
   For Oracle this return null.
   I seted the result to false validity in this case
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to