Skip to content

Commit fe17b44

Browse files
committed
8280414: Memory leak in DefaultProxySelector
Backport-of: fe77250fa450ec803d2818dc90c5bf156521d537
1 parent fd7d0d3 commit fe17b44

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/java.base/windows/native/libnet/DefaultProxySelector.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ static int createProxyList(LPWSTR win_proxy, const WCHAR *pproto, list_item **he
104104
int nr_elems = 0;
105105
wchar_t *context = NULL;
106106
wchar_t *current_proxy = NULL;
107-
BOOL error = FALSE;
108107

109108
/*
110109
* The proxy server list contains one or more of the following strings
@@ -116,7 +115,6 @@ static int createProxyList(LPWSTR win_proxy, const WCHAR *pproto, list_item **he
116115
LPWSTR pport;
117116
LPWSTR phost;
118117
int portVal = 0;
119-
wchar_t *next_proxy = NULL;
120118
list_item *proxy = NULL;
121119
wchar_t* pos = NULL;
122120

@@ -290,7 +288,6 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
290288
}
291289

292290
if (win_proxy != NULL) {
293-
wchar_t *context = NULL;
294291
int defport = 0;
295292
int nr_elems = 0;
296293

@@ -314,27 +311,28 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
314311
nr_elems = createProxyList(win_proxy, lpProto, &head);
315312
if (nr_elems != 0 && head != NULL) {
316313
int index = 0;
314+
list_item *current = head;
317315
proxy_array = (*env)->NewObjectArray(env, nr_elems, proxy_class, NULL);
318316
if (proxy_array == NULL || (*env)->ExceptionCheck(env)) {
319317
goto noproxy;
320318
}
321-
while (head != NULL && index < nr_elems) {
319+
while (current != NULL && index < nr_elems) {
322320
jstring jhost;
323321
jobject isa;
324322
jobject proxy;
325323

326-
if (head->host != NULL && proxy_array != NULL) {
324+
if (current->host != NULL && proxy_array != NULL) {
327325
/* Let's create the appropriate Proxy object then. */
328-
if (head->port == 0) {
329-
head->port = defport;
326+
if (current->port == 0) {
327+
current->port = defport;
330328
}
331-
jhost = (*env)->NewString(env, head->host, (jsize)wcslen(head->host));
329+
jhost = (*env)->NewString(env, current->host, (jsize)wcslen(current->host));
332330
if (jhost == NULL || (*env)->ExceptionCheck(env)) {
333331
proxy_array = NULL;
334332
}
335333
isa = (*env)->CallStaticObjectMethod(env, isaddr_class,
336334
isaddr_createUnresolvedID, jhost,
337-
head->port);
335+
current->port);
338336
if (isa == NULL || (*env)->ExceptionCheck(env)) {
339337
proxy_array = NULL;
340338
}
@@ -348,7 +346,7 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
348346
}
349347
index++;
350348
}
351-
head = head->next;
349+
current = current->next;
352350
}
353351
}
354352
}

0 commit comments

Comments
 (0)