# HG changeset patch # User goetz # Date 1480687330 -3600 # Node ID ecf3e6e5e526049261b1498d1cf3ae981cfdef22 # Parent ddd192238fcbb75ece8d327e5cb9562a9f4c7bfb 8170663: Fix minor issues in corelib and servicabilty coding. Reviewed-by: dsamersoff, dholmes Contributed-by: David CARLIER , goetz.lindenmaier@sap.com diff --git a/src/java.base/share/native/libfdlibm/k_standard.c b/src/java.base/share/native/libfdlibm/k_standard.c --- a/src/java.base/share/native/libfdlibm/k_standard.c +++ b/src/java.base/share/native/libfdlibm/k_standard.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2001, 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 @@ -739,6 +739,8 @@ errno = EDOM; } break; + default: + exc.retval = 0; } return exc.retval; } diff --git a/src/java.base/share/native/libjimage/imageDecompressor.cpp b/src/java.base/share/native/libjimage/imageDecompressor.cpp --- a/src/java.base/share/native/libjimage/imageDecompressor.cpp +++ b/src/java.base/share/native/libjimage/imageDecompressor.cpp @@ -181,7 +181,7 @@ } } while (has_header); memcpy(uncompressed, decompressed_resource, (size_t) uncompressed_size); - delete decompressed_resource; + delete[] decompressed_resource; } // Zip decompressor diff --git a/src/java.base/unix/native/libjli/java_md_solinux.c b/src/java.base/unix/native/libjli/java_md_solinux.c --- a/src/java.base/unix/native/libjli/java_md_solinux.c +++ b/src/java.base/unix/native/libjli/java_md_solinux.c @@ -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 diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/SDE.c b/src/jdk.jdwp.agent/share/native/libjdwp/SDE.c --- a/src/jdk.jdwp.agent/share/native/libjdwp/SDE.c +++ b/src/jdk.jdwp.agent/share/native/libjdwp/SDE.c @@ -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) { diff --git a/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c b/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c --- a/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c +++ b/src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c @@ -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; diff --git a/src/jdk.pack200/share/native/common-unpack/unpack.cpp b/src/jdk.pack200/share/native/common-unpack/unpack.cpp --- a/src/jdk.pack200/share/native/common-unpack/unpack.cpp +++ b/src/jdk.pack200/share/native/common-unpack/unpack.cpp @@ -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());