8230901: missing ReleaseStringUTFChars in serviceability native code
Reviewed-by: stuefe, sspitsyn
--- a/src/java.instrument/share/native/libinstrument/JPLISAgent.c Mon Sep 16 13:53:41 2019 +0200
+++ b/src/java.instrument/share/native/libinstrument/JPLISAgent.c Fri Sep 13 11:04:46 2019 +0200
@@ -1486,6 +1486,7 @@
platformLen = convertUft8ToPlatformString((char*)utf8Chars, utf8Len, platformChars, MAXPATHLEN);
if (platformLen < 0) {
createAndThrowInternalError(jnienv);
+ (*jnienv)->ReleaseStringUTFChars(jnienv, jarFile, utf8Chars);
return;
}
--- a/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp Mon Sep 16 13:53:41 2019 +0200
+++ b/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp Fri Sep 13 11:04:46 2019 +0200
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -692,11 +692,15 @@
char errMsg[ERR_MSG_SIZE];
td_err_e te;
CHECK_EXCEPTION;
+ if (cmdLine_cstr == NULL) {
+ return;
+ }
// some older versions of libproc.so crash when trying to attach 32 bit
// debugger to 64 bit core file. check and throw error.
#ifndef _LP64
- atoi(cmdLine_cstr);
+ errno = 0;
+ strtol(cmdLine_cstr, NULL, 10);
if (errno) {
// core file
int core_fd;
@@ -706,6 +710,7 @@
memcmp(&e32.e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0 &&
e32.e_type == ET_CORE && e32.e_ident[EI_CLASS] == ELFCLASS64) {
close(core_fd);
+ env->ReleaseStringUTFChars(cmdLine, cmdLine_cstr);
THROW_NEW_DEBUGGER_EXCEPTION("debuggee is 64 bit, use java -d64 for debugger");
}
close(core_fd);
@@ -718,6 +723,7 @@
ps_prochandle_t* ph = proc_arg_grab(cmdLine_cstr, (isProcess? PR_ARG_PIDS : PR_ARG_CORES), PGRAB_FORCE, &gcode, NULL);
env->ReleaseStringUTFChars(cmdLine, cmdLine_cstr);
+
if (! ph) {
if (gcode > 0 && gcode < sizeof(proc_arg_grab_errmsgs)/sizeof(const char*)) {
snprintf(errMsg, ERR_MSG_SIZE, "Attach failed : %s", proc_arg_grab_errmsgs[gcode]);