changeset 5807:48c13a79b0f3

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 Mon, 05 Feb 2018 08:48:50 +0000
parents cd276f980df1
children 98853fa789db
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	Mon Feb 05 08:48:50 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2013, 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
@@ -274,13 +274,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) {