librelist archives

« back to archive

NULL ptr exception (w/ fix)

NULL ptr exception (w/ fix)

From:
Date:
2012-03-30 @ 04:27
If one tries to list remotes w/o working NICs, gitno_connect() will 
segfault on cleanup.

fix:
=======================================================


--- src/libgit2/src/netops.c
+++ src/libgit2/src/netops.c
@@ -116,11 +116,12 @@
 
        /* Oops, we couldn't connect to any address */
        error = git__throw(GIT_EOSERR, "Failed to connect: %s", strerror(errno));
 
 cleanup:
-       freeaddrinfo(info);
+       if(info)
+         freeaddrinfo(info);
        return error;
 }
 
 int gitno_send(GIT_SOCKET s, const char *msg, size_t len, int flags)
 {


-- 
Brad Harder
Method Logic Digital Consulting
http://methodlogic.net/
http://twitter.com/bcharder

Re: [libgit2] NULL ptr exception (w/ fix)

From:
Vicent Marti
Date:
2012-03-30 @ 16:48
Cheers! This will be fixed as part of the error handling rewrite.

On Fri, Mar 30, 2012 at 6:27 AM,  <bch@methodlogic.net> wrote:
>
> If one tries to list remotes w/o working NICs, gitno_connect() will 
segfault on cleanup.
>
> fix:
> =======================================================
>
>
> --- src/libgit2/src/netops.c
> +++ src/libgit2/src/netops.c
> @@ -116,11 +116,12 @@
>
>        /* Oops, we couldn't connect to any address */
>        error = git__throw(GIT_EOSERR, "Failed to connect: %s", strerror(errno));
>
>  cleanup:
> -       freeaddrinfo(info);
> +       if(info)
> +         freeaddrinfo(info);
>        return error;
>  }
>
>  int gitno_send(GIT_SOCKET s, const char *msg, size_t len, int flags)
>  {
>
>
> --
> Brad Harder
> Method Logic Digital Consulting
> http://methodlogic.net/
> http://twitter.com/bcharder
>