8170663: Fix minor issues in corelib and servicabilty coding.
Reviewed-by: dsamersoff, dholmes
Contributed-by: David CARLIER <devnexen@gmail.com>, goetz.lindenmaier@sap.com
--- a/jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp Tue Dec 13 18:47:23 2016 -0800
+++ b/jdk/src/java.base/share/native/libjimage/imageDecompressor.cpp Fri Dec 02 15:02:10 2016 +0100
@@ -181,7 +181,7 @@
}
} while (has_header);
memcpy(uncompressed, decompressed_resource, (size_t) uncompressed_size);
- delete decompressed_resource;
+ delete[] decompressed_resource;
}
// Zip decompressor
--- a/jdk/src/java.base/unix/native/libjli/java_md_solinux.c Tue Dec 13 18:47:23 2016 -0800
+++ b/jdk/src/java.base/unix/native/libjli/java_md_solinux.c Fri Dec 02 15:02:10 2016 +0100
@@ -444,13 +444,13 @@
return;
}
#else
- JLI_MemFree(newargv);
- return;
+ JLI_MemFree(newargv);
+ return;
#endif /* SETENV_REQUIRED */
- } else { /* do the same speculatively or exit */
+ } else { /* do the same speculatively or exit */
JLI_ReportErrorMessage(JRE_ERROR2, wanted);
exit(1);
- }
+ }
#ifdef SETENV_REQUIRED
if (mustsetenv) {
/*
@@ -516,14 +516,14 @@
/* runpath contains current effective LD_LIBRARY_PATH setting */
- jvmpath = JLI_StringDup(jvmpath);
+ char *new_jvmpath = JLI_StringDup(jvmpath);
new_runpath_size = ((runpath != NULL) ? JLI_StrLen(runpath) : 0) +
2 * JLI_StrLen(jrepath) + 2 * JLI_StrLen(arch) +
#ifdef AIX
/* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */
JLI_StrLen(jrepath) + JLI_StrLen(arch) + JLI_StrLen("/lib//jli:") +
#endif
- JLI_StrLen(jvmpath) + 52;
+ JLI_StrLen(new_jvmpath) + 52;
new_runpath = JLI_MemAlloc(new_runpath_size);
newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "=");
@@ -533,7 +533,7 @@
*/
{
/* remove the name of the .so from the JVM path */
- lastslash = JLI_StrRChr(jvmpath, '/');
+ lastslash = JLI_StrRChr(new_jvmpath, '/');
if (lastslash)
*lastslash = '\0';
@@ -544,7 +544,7 @@
"%s/lib/%s/jli:" /* Needed on AIX because ld doesn't support $ORIGIN. */
#endif
"%s/../lib/%s",
- jvmpath,
+ new_jvmpath,
jrepath, arch,
#ifdef AIX
jrepath, arch,
@@ -552,6 +552,7 @@
jrepath, arch
);
+ JLI_MemFree(new_jvmpath);
/*
* Check to make sure that the prefix of the current path is the
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/SDE.c Tue Dec 13 18:47:23 2016 -0800
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/SDE.c Fri Dec 02 15:02:10 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2016, 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
@@ -249,16 +249,19 @@
int lastLn = 0;
int sti;
+ if (cnt < 0) {
+ return;
+ }
loadDebugInfo(env, clazz);
if (!isValid()) {
return; /* no SDE or not SourceMap - return unchanged */
}
sti = stratumTableIndex(globalDefaultStratumId);
- if (sti == baseStratumIndex) {
+ if (sti == baseStratumIndex || sti < 0) {
return; /* Java stratum - return unchanged */
}
LOG_MISC(("SDE is re-ordering the line table"));
- for (; cnt-->0; ++fromEntry) {
+ for (; cnt-- > 0; ++fromEntry) {
int jplsLine = fromEntry->line_number;
int lti = stiLineTableIndex(sti, jplsLine);
if (lti >= 0) {
--- a/jdk/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c Tue Dec 13 18:47:23 2016 -0800
+++ b/jdk/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c Fri Dec 02 15:02:10 2016 +0100
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, 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
@@ -196,18 +196,10 @@
} else if (cmd == SO_LINGER) {
struct linger arg;
arg.l_onoff = on;
-
- if(on) {
- arg.l_linger = (unsigned short)value.i;
- if(setsockopt(fd, SOL_SOCKET, SO_LINGER,
- (char*)&arg, sizeof(arg)) < 0) {
- return SYS_ERR;
- }
- } else {
- if (setsockopt(fd, SOL_SOCKET, SO_LINGER,
- (char*)&arg, sizeof(arg)) < 0) {
- return SYS_ERR;
- }
+ arg.l_linger = (on) ? (unsigned short)value.i : 0;
+ if (setsockopt(fd, SOL_SOCKET, SO_LINGER,
+ (char*)&arg, sizeof(arg)) < 0) {
+ return SYS_ERR;
}
} else if (cmd == SO_SNDBUF) {
jint buflen = value.i;
--- a/jdk/src/jdk.pack200/share/native/common-unpack/unpack.cpp Tue Dec 13 18:47:23 2016 -0800
+++ b/jdk/src/jdk.pack200/share/native/common-unpack/unpack.cpp Fri Dec 02 15:02:10 2016 +0100
@@ -2293,10 +2293,15 @@
number.set(null,0);
name = n.slice(dollar2+1, nlen);
}
- if (number.ptr == null)
+ if (number.ptr == null) {
+ if (dollar1 < 0) {
+ abort();
+ return;
+ }
pkgOuter = n.slice(0, dollar1);
- else
+ } else {
pkgOuter.set(null,0);
+ }
PRINTCR((5,"=> %s$ 0%s $%s",
pkgOuter.string(), number.string(), name.string()));
@@ -4197,6 +4202,7 @@
// Note that insnMap has one entry for all these bytes.
--wp; // not really part of the code
int size = bc_escsize.getInt();
+ if (size < 0) { assert(false); continue; }
ensure_put_space(size);
for (int j = 0; j < size; j++)
putu1_fast(bc_escbyte.getByte());