www.libssh2.org | Daily snapshots | Mailing list archive | Docs | Examples | github

Archive Index This month's Index

Subject: Re: OS X Crash in libssh2_session_startup() - EXC_BAD_ACCESS (code=1 address=0x0)

Re: OS X Crash in libssh2_session_startup() - EXC_BAD_ACCESS (code=1 address=0x0)

From: Engstrom, John <john.engstrom_at_tditechnologies.com>
Date: Tue, 1 Sep 2015 09:14:10 -0500

> On Sep 1, 2015, at 4:46 AM, Peter Stuge <peter_at_stuge.se> wrote:
>
> Engstrom, John wrote:
>> Yeah, technically the line "LIBSSH2_SESSION **session;" is actually
>> "LIBSSH2_SESSION **session)" as in it's the last parameter to a function.
>> The calling code passes in the address of a LIBSSH2_SESSION *.
>
> Yes, you dereference a double pointer, but which address does it pass?
>
> If all you have is a pointer to a pointer then you have no actual
> memory where a pointer can be stored. Why are you using a double
> pointer? It seems to be getting you into trouble.
>
>
> //Peter

Peter, the calling code has an auto variable LIBSSH2_SESSION *session . We use the ssh session in other routines - for example where we call libssh2_userauth_list(). Because we are passing the LIBSSH2_SESSION *session into a routine that is responsible for creating the session pointer we pass in the pointer pointer so it can modify the pointer in the caller. Make sense?

John Engstrom
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2015-09-01

the libssh2 team