changeset 4159:c89385610a80 jdk6-b46

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 ef94d044f198
children a74480137e6e
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	Mon Jun 12 13:58:09 2017 -0400
+++ b/src/share/vm/services/attachListener.cpp	Thu Dec 08 15:12:58 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, 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
@@ -276,13 +276,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;
   }
   bool res = CommandLineFlags::uintxAtPut((char*)name, &value, ATTACH_ON_DEMAND);
   if (! res) {