changeset 8357:f8a5d01c0929

8170536: Uninitialised memory in set_uintx_flag of attachListener.cpp Summary: Uninitialised memory in set_uintx_flag of attachListener.cpp Reviewed-by: dholmes, sspitsyn
author dsamersoff
date Thu, 08 Dec 2016 15:12:58 +0300
parents 739246e5f9f3
children c70ebf41026a 00cbb581da94
files src/share/vm/services/attachListener.cpp
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/services/attachListener.cpp	Fri Dec 02 10:39:04 2016 +0000
+++ b/src/share/vm/services/attachListener.cpp	Thu Dec 08 15:12:58 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -271,13 +271,17 @@
 // set a uintx global flag using value from AttachOperation
 static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream* out) {
   uintx value;
-  const char* arg1;
-  if ((arg1 = op->arg(1)) != NULL) {
-    int n = sscanf(arg1, UINTX_FORMAT, &value);
-    if (n != 1) {
-      out->print_cr("flag value must be an unsigned integer");
-      return JNI_ERR;
-    }
+
+  const char* arg1 = op->arg(1);
+  if (arg1 == NULL) {
+    out->print_cr("flag value must be specified");
+    return JNI_ERR;
+  }
+
+  int n = sscanf(arg1, UINTX_FORMAT, &value);
+  if (n != 1) {
+    out->print_cr("flag value must be an unsigned integer");
+    return JNI_ERR;
   }
 
   if (strncmp(name, "MaxHeapFreeRatio", 17) == 0) {