summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2009-10-02 12:45:21 -0700
committerLorenzo Colitti <lorenzo@google.com>2009-10-02 12:53:52 -0700
commit6dbbfbdd8bbc6fd14db672edb6684879d22dea66 (patch)
treedc456d515385d173ac2b4dc7ffb0c392fb95ce9f
parentc8649f2f5476249ab814d8f0e40c295bef873d0d (diff)
downloadlibcore-6dbbfbdd8bbc6fd14db672edb6684879d22dea66.zip
libcore-6dbbfbdd8bbc6fd14db672edb6684879d22dea66.tar.gz
libcore-6dbbfbdd8bbc6fd14db672edb6684879d22dea66.tar.bz2
Make sure res is NULL if getaddrinfo fails.
-rw-r--r--luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp b/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp
index 8b8fe35..29fd217 100644
--- a/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp
+++ b/luni/src/main/native/org_apache_harmony_luni_platform_OSNetworkSystem.cpp
@@ -534,6 +534,7 @@ static jbyteArray osNetworkSystem_ipStringToByteArray(JNIEnv *env, jclass clazz,
jstring javaString) {
if (javaString == NULL) {
throwNullPointerException(env);
+ return NULL;
}
char ipString[INET6_ADDRSTRLEN];
@@ -548,10 +549,12 @@ static jbyteArray osNetworkSystem_ipStringToByteArray(JNIEnv *env, jclass clazz,
}
jbyteArray result = NULL;
- sockaddr_in sin;
- addrinfo hints, *res;
+ addrinfo hints;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_NUMERICHOST;
+
+ sockaddr_in sin;
+ addrinfo *res = NULL;
int ret = getaddrinfo(ipString, NULL, &hints, &res);
if (ret == 0 && res) {
// Convert mapped addresses to IPv4 addresses if necessary.