From 3795f277fb2097b0c94f3ea282fb417f9664a2e4 Mon Sep 17 00:00:00 2001 From: Tsuda Kageyu Date: Wed, 7 Jun 2017 12:12:31 +0900 Subject: [PATCH] Update UTF8-CPP to v2.3.5. --- taglib/toolkit/utf8/checked.h | 14 +++++++------- taglib/toolkit/utf8/core.h | 3 +++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/taglib/toolkit/utf8/checked.h b/taglib/toolkit/utf8/checked.h index 13311551..2aef5838 100644 --- a/taglib/toolkit/utf8/checked.h +++ b/taglib/toolkit/utf8/checked.h @@ -1,4 +1,4 @@ -// Copyright 2006 Nemanja Trifunovic +// Copyright 2006-2016 Nemanja Trifunovic /* Permission is hereby granted, free of charge, to any person or organization @@ -41,7 +41,7 @@ namespace utf8 class invalid_code_point : public exception { uint32_t cp; public: - invalid_code_point(uint32_t cp) : cp(cp) {} + invalid_code_point(uint32_t codepoint) : cp(codepoint) {} virtual const char* what() const throw() { return "Invalid code point"; } uint32_t code_point() const {return cp;} }; @@ -233,7 +233,7 @@ namespace utf8 template u16bit_iterator utf8to16 (octet_iterator start, octet_iterator end, u16bit_iterator result) { - while (start != end) { + while (start < end) { uint32_t cp = utf8::next(start, end); if (cp > 0xffff) { //make a surrogate pair *result++ = static_cast((cp >> 10) + internal::LEAD_OFFSET); @@ -257,7 +257,7 @@ namespace utf8 template u32bit_iterator utf8to32 (octet_iterator start, octet_iterator end, u32bit_iterator result) { - while (start != end) + while (start < end) (*result++) = utf8::next(start, end); return result; @@ -272,9 +272,9 @@ namespace utf8 public: iterator () {} explicit iterator (const octet_iterator& octet_it, - const octet_iterator& range_start, - const octet_iterator& range_end) : - it(octet_it), range_start(range_start), range_end(range_end) + const octet_iterator& rangestart, + const octet_iterator& rangeend) : + it(octet_it), range_start(rangestart), range_end(rangeend) { if (it < range_start || it > range_end) throw std::out_of_range("Invalid utf-8 iterator position"); diff --git a/taglib/toolkit/utf8/core.h b/taglib/toolkit/utf8/core.h index 693d388c..ae0f367d 100644 --- a/taglib/toolkit/utf8/core.h +++ b/taglib/toolkit/utf8/core.h @@ -222,6 +222,9 @@ namespace internal template utf_error validate_next(octet_iterator& it, octet_iterator end, uint32_t& code_point) { + if (it == end) + return NOT_ENOUGH_ROOM; + // Save the original value of it so we can go back in case of failure // Of course, it does not make much sense with i.e. stream iterators octet_iterator original_it = it;