From: David Kalnischkies Date: Sun, 4 Mar 2012 22:56:06 +0000 (+0100) Subject: fix "(error) Possible null pointer dereference: BindAddr" by ensuring X-Git-Tag: 0.9.0~13^2~11 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/ce3c2407d9ac8cc5b45bda5f5991ac0fa89d1d98 fix "(error) Possible null pointer dereference: BindAddr" by ensuring that BindAddr isn't NULL after getaddrinfo() --- diff --git a/methods/ftp.cc b/methods/ftp.cc index b1e8d2b0a..89c81f384 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -721,14 +721,14 @@ bool FTPConn::CreateDataFd() DataListenFd = -1; // Get the information for a listening socket. - struct addrinfo *BindAddr = 0; + struct addrinfo *BindAddr = NULL; struct addrinfo Hints; memset(&Hints,0,sizeof(Hints)); Hints.ai_socktype = SOCK_STREAM; Hints.ai_flags |= AI_PASSIVE; Hints.ai_family = ((struct sockaddr *)&ServerAddr)->sa_family; int Res; - if ((Res = getaddrinfo(0,"0",&Hints,&BindAddr)) != 0) + if ((Res = getaddrinfo(0,"0",&Hints,&BindAddr)) != 0 || BindAddr == NULL) return _error->Error(_("getaddrinfo was unable to get a listening socket")); // Construct the socket