diff --git a/cpp/core/src/zxing/oned/Code128Reader.cpp b/cpp/core/src/zxing/oned/Code128Reader.cpp index 7b088219b..b76536a4f 100644 --- a/cpp/core/src/zxing/oned/Code128Reader.cpp +++ b/cpp/core/src/zxing/oned/Code128Reader.cpp @@ -376,11 +376,14 @@ namespace zxing { } break; case CODE_CODE_C: - // the code read in this case is the number encoded directly + tmpResultSStr.str(std::string()); + // the code read in this case is the number encoded directly if (code < 100) { - if (code < 10) - tmpResultSStr << '0'; - tmpResultSStr << code; + if (code < 10) { + tmpResultSStr << '0'; + } + tmpResultSStr << code; + tmpResultString.append(tmpResultSStr.str()); } else { if (code != CODE_STOP) { lastCharacterWasPrintable = false; @@ -438,9 +441,6 @@ namespace zxing { throw ReaderException(""); } - if (codeSet == CODE_CODE_C) - tmpResultString.append(tmpResultSStr.str()); - // Need to pull out the check digits from string int resultLength = tmpResultString.length(); // Only bother if the result had at least one character, and if the checksum digit happened to