Merge: lib/socket: Bugfix
authorJean Privat <jean@pryen.org>
Wed, 9 Apr 2014 18:08:07 +0000 (14:08 -0400)
committerJean Privat <jean@pryen.org>
Wed, 9 Apr 2014 18:08:07 +0000 (14:08 -0400)
Bug introduced in pull request #377, in the read function of FFSocket, a free is called on a static variable, which provokes a warning and probably bugs at runtime.

Pull-Request: #389

lib/socket/socket_c.nit

index 11bda16..1d56bcb 100644 (file)
@@ -124,13 +124,11 @@ extern FFSocket `{ S_DESCRIPTOR* `}
                static char c[1024];
                int n = read(*recv, c, 1024);
                if(n < 0) {
-                       free(c);
                        return NativeString_to_s_with_length("",0);
                }
                char* ret = malloc(n + 1);
                memcpy(ret, c, n);
                ret[n] = '\0';
-               free(c);
                return NativeString_to_s_with_length(ret, n);
        `}