core: protect access to _items in empty strings
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 7 Sep 2017 15:48:34 +0000 (11:48 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 15 Sep 2017 12:25:57 +0000 (08:25 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/core/bytes.nit
lib/core/text/flat.nit

index 882a6e9..41b6aa8 100644 (file)
@@ -931,7 +931,7 @@ end
 redef class FlatText
        redef fun append_to_bytes(b) do
                var from = if self isa FlatString then first_byte else 0
-               b.append_ns_from(items, byte_length, from)
+               if isset _items then b.append_ns_from(items, byte_length, from)
        end
 end
 
index 06cdcfe..b728e42 100644 (file)
@@ -1205,7 +1205,7 @@ private class FlatBufferByteIterator
 
        var curr_pos: Int
 
-       init do target_items = target._items
+       init do if isset target._items then target_items = target._items
 
        redef fun index do return curr_pos