Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8318671

Potential uninitialized uintx value after JDK-8317683

XMLWordPrintable

    • b24

      SonarCloud reports a problem in new code added by JDK-8317683.

      parseEnumValueAsUintx can return "true" without initializing the "value", at which point we pass uninitialized value to register_command.

      Here:

      ```
        } else if (type == OptionType::Uintx) {
          uintx value;
          // Is it a named enum?
          bool success = parseEnumValueAsUintx(option, line, value, bytes_read, errorbuf, buf_size);
          if (!success) {
            // Is it a raw number?
            success = (sscanf(line, "" UINTX_FORMAT "%n", &value, &bytes_read) == 1);
          }
          if (success) {
            total_bytes_read += bytes_read;
            line += bytes_read;
            register_command(matcher, option, value); <--- value can be not initialized
            return;
          } else {
            jio_snprintf(errorbuf, buf_size, "Value cannot be read for option '%s' of type '%s'", ccname, type_str);
          }
      ```

            stuefe Thomas Stuefe
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: