lib/core: fix segfaults in `String::realpath` and remove fixed FIXME
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 8 Dec 2015 15:09:34 +0000 (10:09 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 8 Dec 2015 15:09:34 +0000 (10:09 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/core/file.nit

index 03955eb..fd848e1 100644 (file)
@@ -959,10 +959,13 @@ redef class String
        end
 
        # Return the canonicalized absolute pathname (see POSIX function `realpath`)
+       #
+       # Require: `file_exists`
        fun realpath: String do
                var cs = to_cstring.file_realpath
+               assert file_exists
                var res = cs.to_s_with_copy
-               # cs.free_malloc # FIXME memory leak
+               cs.free
                return res
        end