lib/standard/time: Fixed String-related memory leak
authorLucas Bajolet <r4pass@hotmail.com>
Tue, 3 Feb 2015 21:47:39 +0000 (16:47 -0500)
committerLucas Bajolet <r4pass@hotmail.com>
Thu, 5 Feb 2015 16:08:57 +0000 (11:08 -0500)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/time.nit

index 09e8389..e0b3867 100644 (file)
@@ -135,7 +135,9 @@ extern class Tm `{struct tm *`}
                c_format = String_to_cstring(format);
 
                res = strftime(buf, 100, c_format, recv);
-               return NativeString_to_s(buf);
+               String s = NativeString_to_s_with_copy(buf);
+               free(buf);
+               return s;
        `}
 
        redef fun to_s do return asctime.replace("\n", "")