lib/standard/string: Fix the case of null items in FlatBuffer when calling to_s
authorLucas Bajolet <r4pass@hotmail.com>
Fri, 19 Sep 2014 19:01:57 +0000 (15:01 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Fri, 19 Sep 2014 19:01:57 +0000 (15:01 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/string.nit

index 1319b26..c595162 100644 (file)
@@ -657,6 +657,10 @@ end
 abstract class FlatText
        super Text
 
+       # Underlying C-String (`char*`)
+       #
+       # Warning : Might be void in some subclasses, be sure to check
+       # if set before using it.
        private var items: NativeString
 
        # Real items, used as cache for to_cstring is called
@@ -1358,6 +1362,7 @@ class FlatBuffer
        redef fun to_s: String
        do
                written = true
+               if length == 0 then items = new NativeString(1)
                return new FlatString.with_infos(items, length, 0, length - 1)
        end