8170536: Uninitialised memory in set_uintx_flag of attachListener.cpp

Thu, 08 Dec 2016 15:12:58 +0300

author
dsamersoff
date
Thu, 08 Dec 2016 15:12:58 +0300
changeset 8658
f8a5d01c0929
parent 8657
739246e5f9f3
child 8659
c70ebf41026a
child 8664
00cbb581da94

8170536: Uninitialised memory in set_uintx_flag of attachListener.cpp
Summary: Uninitialised memory in set_uintx_flag of attachListener.cpp
Reviewed-by: dholmes, sspitsyn

src/share/vm/services/attachListener.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/services/attachListener.cpp	Fri Dec 02 10:39:04 2016 +0000
     1.2 +++ b/src/share/vm/services/attachListener.cpp	Thu Dec 08 15:12:58 2016 +0300
     1.3 @@ -1,5 +1,5 @@
     1.4  /*
     1.5 - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
     1.6 + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
     1.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.8   *
     1.9   * This code is free software; you can redistribute it and/or modify it
    1.10 @@ -271,13 +271,17 @@
    1.11  // set a uintx global flag using value from AttachOperation
    1.12  static jint set_uintx_flag(const char* name, AttachOperation* op, outputStream* out) {
    1.13    uintx value;
    1.14 -  const char* arg1;
    1.15 -  if ((arg1 = op->arg(1)) != NULL) {
    1.16 -    int n = sscanf(arg1, UINTX_FORMAT, &value);
    1.17 -    if (n != 1) {
    1.18 -      out->print_cr("flag value must be an unsigned integer");
    1.19 -      return JNI_ERR;
    1.20 -    }
    1.21 +
    1.22 +  const char* arg1 = op->arg(1);
    1.23 +  if (arg1 == NULL) {
    1.24 +    out->print_cr("flag value must be specified");
    1.25 +    return JNI_ERR;
    1.26 +  }
    1.27 +
    1.28 +  int n = sscanf(arg1, UINTX_FORMAT, &value);
    1.29 +  if (n != 1) {
    1.30 +    out->print_cr("flag value must be an unsigned integer");
    1.31 +    return JNI_ERR;
    1.32    }
    1.33  
    1.34    if (strncmp(name, "MaxHeapFreeRatio", 17) == 0) {

mercurial