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

Incorrect implementation of JDK_Version::to_string OR proper return statement is missing

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 10
    • 8, 9
    • hotspot
    • b21

        707 void JDK_Version::to_string(char* buffer, size_t buflen) const {
        708 assert(buffer && buflen > 0, "call with useful buffer");
        709 size_t index = 0;
        710
        711 if (!is_valid()) {
        712 jio_snprintf(buffer, buflen, "%s", "(uninitialized)");
        713 } else {
        714 int rc = jio_snprintf(
        715 &buffer[index], buflen - index, "%d.%d", _major, _minor);
        716 if (rc == -1) return;
        717 index += rc;
        718 if (_security > 0) {
        719 rc = jio_snprintf(&buffer[index], buflen - index, ".%d", _security);
        720 }
        721 if (_patch > 0) {
        722 rc = jio_snprintf(&buffer[index], buflen - index, ".%d", _patch);
        723 if (rc == -1) return;
        724 index += rc;
        725 }
        726 if (_build > 0) {
        727 rc = jio_snprintf(&buffer[index], buflen - index, "+%d", _build);
        728 if (rc == -1) return;
        729 index += rc;
        730 }
        731 }
        732 }

        Not sure about the different set of values of different flags [_security, _patch and _build]. Let us consider two scenario:
         1. Not sure about the possibility but if flags _security > 0 and _patch or _build > 0 then in that case the effect of code at line# 719 will be null and void by code at line# 722 or line# 727 depending on the values of flag _patch and _build.
         2. If _security is non zero and other flag can not be non zero then in that case it is better to put return statement after line# 719 to avoid confusion.

              shshahma Shafi Ahmad (Inactive)
              shshahma Shafi Ahmad (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: