Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
8280414: Memory leak in DefaultProxySelector
Backport-of: fe77250fa450ec803d2818dc90c5bf156521d537
  • Loading branch information
Olga Mikhaltsova committed Jan 31, 2022
1 parent b8a13bc commit e95ff4d
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/java.base/windows/native/libnet/DefaultProxySelector.c
Expand Up @@ -104,7 +104,6 @@ static int createProxyList(LPWSTR win_proxy, const WCHAR *pproto, list_item **he
int nr_elems = 0;
wchar_t *context = NULL;
wchar_t *current_proxy = NULL;
BOOL error = FALSE;

/*
* The proxy server list contains one or more of the following strings
Expand All @@ -116,7 +115,6 @@ static int createProxyList(LPWSTR win_proxy, const WCHAR *pproto, list_item **he
LPWSTR pport;
LPWSTR phost;
int portVal = 0;
wchar_t *next_proxy = NULL;
list_item *proxy = NULL;
wchar_t* pos = NULL;

Expand Down Expand Up @@ -290,7 +288,6 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
}

if (win_proxy != NULL) {
wchar_t *context = NULL;
int defport = 0;
int nr_elems = 0;

Expand All @@ -313,27 +310,28 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
nr_elems = createProxyList(win_proxy, lpProto, &head);
if (nr_elems != 0 && head != NULL) {
int index = 0;
list_item *current = head;
proxy_array = (*env)->NewObjectArray(env, nr_elems, proxy_class, NULL);
if (proxy_array == NULL || (*env)->ExceptionCheck(env)) {
goto noproxy;
}
while (head != NULL && index < nr_elems) {
while (current != NULL && index < nr_elems) {
jstring jhost;
jobject isa;
jobject proxy;

if (head->host != NULL && proxy_array != NULL) {
if (current->host != NULL && proxy_array != NULL) {
/* Let's create the appropriate Proxy object then. */
if (head->port == 0) {
head->port = defport;
if (current->port == 0) {
current->port = defport;
}
jhost = (*env)->NewString(env, head->host, (jsize)wcslen(head->host));
jhost = (*env)->NewString(env, current->host, (jsize)wcslen(current->host));
if (jhost == NULL || (*env)->ExceptionCheck(env)) {
proxy_array = NULL;
}
isa = (*env)->CallStaticObjectMethod(env, isaddr_class,
isaddr_createUnresolvedID, jhost,
head->port);
current->port);
if (isa == NULL || (*env)->ExceptionCheck(env)) {
proxy_array = NULL;
}
Expand All @@ -347,7 +345,7 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
}
index++;
}
head = head->next;
current = current->next;
}
}
}
Expand Down

1 comment on commit e95ff4d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.