From fa1bd4fb25c5fb738010e77f1244161727b5f7bd Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 19 Oct 2007 23:33:37 +0000 Subject: [PATCH] Fix handling of wide string merge sections. --- gold/merge.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gold/merge.cc b/gold/merge.cc index b5c836f..80d2d1a 100644 --- a/gold/merge.cc +++ b/gold/merge.cc @@ -259,16 +259,17 @@ Output_merge_string::do_add_input_section(Relobj* object, "character size")); return false; } - len /= sizeof(Char_type); + // The index I is in bytes, not characters. off_t i = 0; while (i < len) { off_t plen = 0; for (const Char_type* pl = p; *pl != 0; ++pl) { + // The length PLEN is in characters, not bytes. ++plen; - if (i + plen >= len) + if (i + plen * sizeof(Char_type) >= len) { object->error(_("entry in mergeable string section " "not null terminated")); @@ -281,7 +282,7 @@ Output_merge_string::do_add_input_section(Relobj* object, this->merged_strings_.push_back(Merged_string(object, shndx, i, str)); p += plen + 1; - i += plen + 1; + i += (plen + 1) * sizeof(Char_type); } return true; -- 2.7.4