[hamradio-commits] [gnss-sdr] 37/149: fix defect detected by coverity scan

Carles Fernandez carles_fernandez-guest at moszumanska.debian.org
Sat Feb 6 19:43:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

carles_fernandez-guest pushed a commit to branch next
in repository gnss-sdr.

commit 5743f0f631f4a453b3ef7a13d81734ec3c3c9f0c
Author: Carles Fernandez <carles.fernandez at gmail.com>
Date:   Wed Jan 6 14:30:15 2016 +0100

    fix defect detected by coverity scan
    
    aStr->find('.', startPos) can return a negative number, but idx was
    passed to a parameter that cannot be negative. Now the function returns
    the string as is in case of no decimal point found.
---
 src/algorithms/PVT/libs/rinex_printer.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h
index 876ce34..2307e60 100644
--- a/src/algorithms/PVT/libs/rinex_printer.h
+++ b/src/algorithms/PVT/libs/rinex_printer.h
@@ -515,9 +515,10 @@ inline std::string & Rinex_Printer::sci2for(std::string & aStr,
     bool redoexp =! checkSwitch;
 
     // Check for decimal place within specified boundaries
-    if ((idx == 0) || (idx >= (startPos + length - expLen - 1)))
+    if ((idx <= 0) || (idx >= (startPos + length - expLen - 1)))
         {
             // Error: no decimal point in string
+            return aStr;
         }
 
     // Here, account for the possibility that there are
@@ -525,12 +526,12 @@ inline std::string & Rinex_Printer::sci2for(std::string & aStr,
     // account for the possibility of non-scientific
     // notation (more than one digit to the left of the
     // decimal)
-    if ((idx > startPos) && (idx >= 1))
+    if (idx > startPos)
         {
             redoexp = true;
             // Swap digit and decimal.
-            aStr[static_cast<unsigned int>(idx)] = aStr[static_cast<unsigned int>(idx - 1)];
-            aStr[static_cast<unsigned int>(idx - 1)] = '.';
+            aStr[idx] = aStr[idx - 1];
+            aStr[idx - 1] = '.';
             // Only add one to the exponent if the number is non-zero
             if (asDouble(aStr.substr(startPos, length)) != 0.0)
                 expAdd = 1;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/gnss-sdr.git



More information about the pkg-hamradio-commits mailing list