Skip to content

Commit

Permalink
Fix valgrind invalid read
Browse files Browse the repository at this point in the history
But might have performance impact; need to check
  • Loading branch information
chainsawriot committed Sep 28, 2023
1 parent 624da84 commit 9c90f9c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/adaR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ std::string charsub(const ada_string stringi) {
const char* res = stringi.data;
size_t len = stringi.length;
ada_owned_string stringi_new = ada_idna_to_unicode(res, len);
res = stringi_new.data;
len = stringi_new.length;
std::string output = std::string(res, 0, len);
std::string_view output(stringi_new.data, stringi_new.length);
std::string output2 = {output.begin(), output.end()};
ada_free_owned_string(stringi_new);
return output;
return output2;
}

// [[Rcpp::export]]
Expand Down

0 comments on commit 9c90f9c

Please sign in to comment.