From 3e5b58e0d706a3e9b221416aab91a44c92c36aac Mon Sep 17 00:00:00 2001 From: Christoph Langer Date: Fri, 23 Mar 2018 09:26:59 +0100 Subject: [PATCH] 8199924: Solaris: Correctly enqueue null arguments of attach operations Reviewed-by: dcubed, dholmes --- .../solaris/native/libattach/VirtualMachineImpl.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c b/src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c index fb40983f3be..f72bdeb3833 100644 --- a/src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c +++ b/src/jdk.attach/solaris/native/libattach/VirtualMachineImpl.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2018, 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 @@ -231,7 +231,7 @@ static const char* translate_error(jint err) { int table_size = sizeof(error_messages) / sizeof(error_messages[0]); int i; - for (i=0; iGetArrayLength(env, args); - for (i=0; iGetObjectArrayElement(env, args, i); if (obj != NULL) { cstr = JNU_GetStringPlatformChars(env, obj, &isCopy); @@ -314,6 +314,15 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_enqueue return -1; } } + } else { + char* newbuf = (char*)realloc(buf, size + 1); + if (newbuf == NULL) { + free(buf); + JNU_ThrowOutOfMemoryError(env, "realloc failed"); + return -1; + } + buf = newbuf; + buf[size++] = 0; } if ((*env)->ExceptionOccurred(env)) { free(buf);