From: Wolfgang J. <wo....@ka...> - 2016-11-24 22:51:39
|
Hi Eric, I found an fatal error in routine READABLE_STRING_8.copy if the argument is a non-void but empty string. The origin text is as follows: copy (other: like Current) -- Reinitialize by copying the characters of `other'. -- (This is also used by `twin'.) local old_area: like area do if other /= Current then old_area := area standard_copy (other) -- Note: <= is needed as all Eiffel string should have an -- extra character to insert null character at the end. if old_area = Void or else old_area = other.area or else old_area.count <= count then -- Prevent copying of large `area' if only a few characters are actually used. area := area.resized_area (count + 1) else old_area.copy_data (area, 0, 0, count) area := old_area end internal_hash_code := 0 end ensure then new_result_count: count = other.count -- same_characters: For every `i' in 1..`count', `item' (`i') = `other'.`item' (`i') end If the string to copy is empty, i.e. `old_area=Void' then `area' is void, too, after `standard_copy'. Then branch `if old_area=Void or else ...' leads to instruction `area := area.resized_area (count + 1)' that must crash. I propose the following modification (it works fine for me): copy (other: like Current) -- Reinitialize by copying the characters of `other'. -- (This is also used by `twin'.) local old_area: like area do if other /= Current then old_area := area standard_copy (other) -- Note: <= is needed as all Eiffel string should have an -- extra character to insert null character at the end. if old_area = Void then elseif old_area = other.area or else old_area.count <= count then -- Prevent copying of large `area' if only a few characters are actually used. area := area.resized_area (count + 1) else old_area.copy_data (area, 0, 0, count) area := old_area end internal_hash_code := 0 end ensure then new_result_count: count = other.count -- same_characters: For every `i' in 1..`count', `item' (`i') = `other'.`item' (`i') end I do not know whether the bug is already in ISE's distribution of the class. Best regards Wolfgang -- Dr. Wolfgang Jansen Lauenburger Straße 40 D-12169 Berlin Tel: (+49) 0172 40 86 916 e-mail: wo....@ka... |