8186825: some memory leak issues in the transport_startTransport
Reviewed-by: sspitsyn, phh
This commit is contained in:
parent
9516e6d2fd
commit
0edf6c1341
@ -49,6 +49,15 @@ typedef struct TransportInfo {
|
|||||||
|
|
||||||
static struct jdwpTransportCallback callback = {jvmtiAllocate, jvmtiDeallocate};
|
static struct jdwpTransportCallback callback = {jvmtiAllocate, jvmtiDeallocate};
|
||||||
|
|
||||||
|
static void freeTransportInfo(TransportInfo *info) {
|
||||||
|
if (info) {
|
||||||
|
jvmtiDeallocate(info->name);
|
||||||
|
jvmtiDeallocate(info->address);
|
||||||
|
jvmtiDeallocate(info->allowed_peers);
|
||||||
|
jvmtiDeallocate(info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print the last transport error
|
* Print the last transport error
|
||||||
*/
|
*/
|
||||||
@ -345,12 +354,14 @@ acceptThread(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg)
|
|||||||
|
|
||||||
LOG_MISC(("Begin accept thread"));
|
LOG_MISC(("Begin accept thread"));
|
||||||
|
|
||||||
info = (TransportInfo*)(void*)arg;
|
info = (TransportInfo*)arg;
|
||||||
t = info->transport;
|
t = info->transport;
|
||||||
rc = (*t)->Accept(t, info->timeout, 0);
|
rc = (*t)->Accept(t, info->timeout, 0);
|
||||||
|
|
||||||
/* System property no longer needed */
|
/* System property no longer needed */
|
||||||
setTransportProperty(jni_env, NULL);
|
setTransportProperty(jni_env, NULL);
|
||||||
|
/* TransportInfo data no longer needed */
|
||||||
|
freeTransportInfo(info);
|
||||||
|
|
||||||
if (rc != JDWPTRANSPORT_ERROR_NONE) {
|
if (rc != JDWPTRANSPORT_ERROR_NONE) {
|
||||||
/*
|
/*
|
||||||
@ -371,10 +382,14 @@ acceptThread(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg)
|
|||||||
static void JNICALL
|
static void JNICALL
|
||||||
attachThread(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg)
|
attachThread(jvmtiEnv* jvmti_env, JNIEnv* jni_env, void* arg)
|
||||||
{
|
{
|
||||||
TransportInfo *info = (TransportInfo*)(void*)arg;
|
TransportInfo *info = (TransportInfo*)arg;
|
||||||
|
jdwpTransportEnv *t = info->transport;
|
||||||
|
|
||||||
|
/* TransportInfo data no longer needed */
|
||||||
|
freeTransportInfo(info);
|
||||||
|
|
||||||
LOG_MISC(("Begin attach thread"));
|
LOG_MISC(("Begin attach thread"));
|
||||||
connectionInitiated(info->transport);
|
connectionInitiated(t);
|
||||||
LOG_MISC(("End attach thread"));
|
LOG_MISC(("End attach thread"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +499,7 @@ transport_startTransport(jboolean isServer, char *name, char *address,
|
|||||||
if (info->transport == NULL) {
|
if (info->transport == NULL) {
|
||||||
serror = loadTransport(name, info);
|
serror = loadTransport(name, info);
|
||||||
if (serror != JDWP_ERROR(NONE)) {
|
if (serror != JDWP_ERROR(NONE)) {
|
||||||
jvmtiDeallocate(info);
|
freeTransportInfo(info);
|
||||||
return serror;
|
return serror;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -577,6 +592,9 @@ transport_startTransport(jboolean isServer, char *name, char *address,
|
|||||||
goto handleError;
|
goto handleError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* reset info - it will be deallocated by acceptThread */
|
||||||
|
info = NULL;
|
||||||
|
|
||||||
launchCommand = debugInit_launchOnInit();
|
launchCommand = debugInit_launchOnInit();
|
||||||
if (launchCommand != NULL) {
|
if (launchCommand != NULL) {
|
||||||
serror = launch(launchCommand, name, retAddress);
|
serror = launch(launchCommand, name, retAddress);
|
||||||
@ -592,10 +610,7 @@ transport_startTransport(jboolean isServer, char *name, char *address,
|
|||||||
return JDWP_ERROR(NONE);
|
return JDWP_ERROR(NONE);
|
||||||
|
|
||||||
handleError:
|
handleError:
|
||||||
jvmtiDeallocate(info->name);
|
freeTransportInfo(info);
|
||||||
jvmtiDeallocate(info->address);
|
|
||||||
jvmtiDeallocate(info->allowed_peers);
|
|
||||||
jvmtiDeallocate(info);
|
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Note that we don't attempt to do a launch here. Launching
|
* Note that we don't attempt to do a launch here. Launching
|
||||||
@ -614,7 +629,7 @@ handleError:
|
|||||||
/* The name, address and allowed_peers fields in 'info'
|
/* The name, address and allowed_peers fields in 'info'
|
||||||
* are not allocated in the non-server case so
|
* are not allocated in the non-server case so
|
||||||
* they do not need to be freed. */
|
* they do not need to be freed. */
|
||||||
jvmtiDeallocate(info);
|
freeTransportInfo(info);
|
||||||
return serror;
|
return serror;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user