Mercurial > octave
changeset 31970:701fbdfb3bc0 stable
codecvt_u8: Avoid random segmentation faults with libc++ (bug #63930).
* liboctave/util/oct-string.cc (octave::string::codecvt_u8::do_out): Set valid
values for pointers that are passed by reference before returning early.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Wed, 05 Apr 2023 18:11:52 +0200 |
parents | 63038dcbd648 |
children | 37700c8fba9c 87beb2f167ea |
files | liboctave/util/oct-string.cc |
diffstat | 1 files changed, 6 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/util/oct-string.cc Mon Apr 03 17:09:17 2023 +0200 +++ b/liboctave/util/oct-string.cc Wed Apr 05 18:11:52 2023 +0200 @@ -617,8 +617,12 @@ const InternT* from, const InternT* from_end, const InternT*& from_next, ExternT* to, ExternT* to_end, ExternT*& to_next) const { + to_next = to; if (from_end <= from) - return std::codecvt<InternT, ExternT, StateT>::noconv; + { + from_next = from_end; + return std::codecvt<InternT, ExternT, StateT>::noconv; + } // Check if buffer ends in a complete UTF-8 surrogate. // FIXME: If this is the last call before a stream is closed, we should @@ -649,6 +653,7 @@ && (num_bytes_in_buf < 4))) // incomplete 4-byte surrogate pop_end = num_bytes_in_buf; } + from_next = from_end - pop_end; std::size_t srclen = (from_end-from-pop_end) * sizeof (InternT); std::size_t length = (to_end-to) * sizeof (ExternT);