Skip to content

Commit fe77250

Browse files
djelinskidfuch
authored andcommitted
8280414: Memory leak in DefaultProxySelector
Reviewed-by: dfuchs
1 parent 496baad commit fe77250

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

@@ -292,7 +290,6 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
292290
}
293291

294292
if (win_proxy != NULL) {
295-
wchar_t *context = NULL;
296293
int defport = 0;
297294
int nr_elems = 0;
298295

@@ -315,27 +312,28 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
315312
nr_elems = createProxyList(win_proxy, lpProto, &head);
316313
if (nr_elems != 0 && head != NULL) {
317314
int index = 0;
315+
list_item *current = head;
318316
proxy_array = (*env)->NewObjectArray(env, nr_elems, proxy_class, NULL);
319317
if (proxy_array == NULL || (*env)->ExceptionCheck(env)) {
320318
goto noproxy;
321319
}
322-
while (head != NULL && index < nr_elems) {
320+
while (current != NULL && index < nr_elems) {
323321
jstring jhost;
324322
jobject isa;
325323
jobject proxy;
326324

327-
if (head->host != NULL && proxy_array != NULL) {
325+
if (current->host != NULL && proxy_array != NULL) {
328326
/* Let's create the appropriate Proxy object then. */
329-
if (head->port == 0) {
330-
head->port = defport;
327+
if (current->port == 0) {
328+
current->port = defport;
331329
}
332-
jhost = (*env)->NewString(env, head->host, (jsize)wcslen(head->host));
330+
jhost = (*env)->NewString(env, current->host, (jsize)wcslen(current->host));
333331
if (jhost == NULL || (*env)->ExceptionCheck(env)) {
334332
proxy_array = NULL;
335333
}
336334
isa = (*env)->CallStaticObjectMethod(env, isaddr_class,
337335
isaddr_createUnresolvedID, jhost,
338-
head->port);
336+
current->port);
339337
if (isa == NULL || (*env)->ExceptionCheck(env)) {
340338
proxy_array = NULL;
341339
}
@@ -349,7 +347,7 @@ Java_sun_net_spi_DefaultProxySelector_getSystemProxies(JNIEnv *env,
349347
}
350348
index++;
351349
}
352-
head = head->next;
350+
current = current->next;
353351
}
354352
}
355353
}

0 commit comments

Comments
 (0)