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

Commit 1f039b3

Browse files
committed
8280414: Memory leak in DefaultProxySelector
Backport-of: fe77250fa450ec803d2818dc90c5bf156521d537
1 parent 68a0807 commit 1f039b3

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

@@ -313,27 +310,28 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
313310
nr_elems = createProxyList(win_proxy, lpProto, &head);
314311
if (nr_elems != 0 && head != NULL) {
315312
int index = 0;
313+
list_item *current = head;
316314
proxy_array = (*env)->NewObjectArray(env, nr_elems, proxy_class, NULL);
317315
if (proxy_array == NULL || (*env)->ExceptionCheck(env)) {
318316
goto noproxy;
319317
}
320-
while (head != NULL && index < nr_elems) {
318+
while (current != NULL && index < nr_elems) {
321319
jstring jhost;
322320
jobject isa;
323321
jobject proxy;
324322

325-
if (head->host != NULL && proxy_array != NULL) {
323+
if (current->host != NULL && proxy_array != NULL) {
326324
/* Let's create the appropriate Proxy object then. */
327-
if (head->port == 0) {
328-
head->port = defport;
325+
if (current->port == 0) {
326+
current->port = defport;
329327
}
330-
jhost = (*env)->NewString(env, head->host, (jsize)wcslen(head->host));
328+
jhost = (*env)->NewString(env, current->host, (jsize)wcslen(current->host));
331329
if (jhost == NULL || (*env)->ExceptionCheck(env)) {
332330
proxy_array = NULL;
333331
}
334332
isa = (*env)->CallStaticObjectMethod(env, isaddr_class,
335333
isaddr_createUnresolvedID, jhost,
336-
head->port);
334+
current->port);
337335
if (isa == NULL || (*env)->ExceptionCheck(env)) {
338336
proxy_array = NULL;
339337
}
@@ -347,7 +345,7 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
347345
}
348346
index++;
349347
}
350-
head = head->next;
348+
current = current->next;
351349
}
352350
}
353351
}

0 commit comments

Comments
 (0)