Review at https://gerrit.osmocom.org/3324
sock_src_init(): Don't freeaddrinfo() undefined src_result
src_result is only valid "if (src)", so we cannot unconditionally free it:
(gdb) bt host=0x52 <error: Cannot access memory at address 0x52>, src=0x0) at /usr/src/debug/osmo-pcap/0.0.6+gitrAUTOINC+4776b2972e-r1d/git/src/osmo_client_network.c:165
Change-Id: I3b6778d9110583ecb1daec59ef2c86465d5818b9 --- M src/osmo_client_network.c 1 file changed, 2 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-pcap refs/changes/24/3324/1
diff --git a/src/osmo_client_network.c b/src/osmo_client_network.c index 937caa0..27c649a 100644 --- a/src/osmo_client_network.c +++ b/src/osmo_client_network.c @@ -162,7 +162,8 @@ close(sfd); } freeaddrinfo(result); - freeaddrinfo(src_result); + if (src) + freeaddrinfo(src_result);
if (rp == NULL) { fprintf(stderr, "unable to connect/bind socket: %s:%u: %s\n",
Patch Set 1: Code-Review+1
(2 comments)
https://gerrit.osmocom.org/#/c/3324/1/src/osmo_client_network.c File src/osmo_client_network.c:
Line 47: * Move to libosmocore... if the api makes source s/source/sense/ lol...
Line 165: if (src) Why not src_result directly?
Patch Set 1:
(1 comment)
https://gerrit.osmocom.org/#/c/3324/1/src/osmo_client_network.c File src/osmo_client_network.c:
Line 165: if (src)
Why not src_result directly?
because it's not initialized with NULL, so we cannot check if it contains random chunk or valid data. Hence I used the same condition that you use before getaddrinfo().
Patch Set 1: Code-Review+2
(1 comment)
This explains the crash. Do you have a backtrace as well? It would be interesting to see why it is NULL. But very minor issue so let's not lose too much time here.