[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kstars-devel
Subject:    Re: [Kstars-devel] Fwd: KStars Crashes While loading in Ubuntu 11.10
From:       Alexey Khudyakov <alexey.skladnoy () gmail ! com>
Date:       2011-10-22 10:23:37
Message-ID: 4EA299A9.80500 () gmail ! com
[Download RAW message or body]

On 16.10.2011 00:51, Alexey Khudyakov wrote:
> On 15.10.2011 06:44, Akarsh Simha wrote:
>>> I have a feeling that it's upstream, because I can't reproduce it. I
>>
> Was anyone able to reproduce bug? Here few observations I made from
> reading reports:
>
#279026 turned out to be fairly trivial to fix once pinpointed.
Could someone apply it to both master and 4.7 branch? I have
some troubles with ssh keys.

["0001-Fix-infamous-279026-crash-bug.patch" (text/x-patch)]

From 5b852753cef50b0406ff0213c3a67e5e7cb94983 Mon Sep 17 00:00:00 2001
From: Khudyakov Alexey <alexey.skladnoy@gmail.com>
Date: Sat, 22 Oct 2011 13:52:09 +0400
Subject: [PATCH] Fix infamous 279026 crash bug.

New code expect astroids.dat and comets.dat in csv format with
23 and 21 columns respectively. But it doesn't check that format
is correct and this results in reading beyond end of array
with results we all were able to observe

Trivial to fix if spotted.
---
 kstars/skycomponents/asteroidscomponent.cpp |   18 ++++++++----------
 kstars/skycomponents/cometscomponent.cpp    |   11 ++++-------
 2 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/kstars/skycomponents/asteroidscomponent.cpp b/kstars/skycomponents/asteroidscomponent.cpp
index a7d6c14..7f44926 100644
--- a/kstars/skycomponents/asteroidscomponent.cpp
+++ b/kstars/skycomponents/asteroidscomponent.cpp
@@ -105,14 +105,15 @@ void AsteroidsComponent::loadData()
         line = fileReader.readLine();
 
         // Ignore comments and too short lines
-        if ( line.at( 0 ) == '#' || line.size() < 8 )
+        if ( line.size() < 8 || line.at( 0 ) == '#' )
             continue;
-
         fields = line.split( "," );
+        if ( fields.size() < 23 )
+            continue;
 
         full_name = fields.at( 0 );
-        full_name   = full_name.remove( '"' ).trimmed();
-        int catN = full_name.section( " ", 0, 0 ).toInt();
+        full_name = full_name.remove( '"' ).trimmed();
+        int catN  = full_name.section( " ", 0, 0 ).toInt();
         name = full_name.section( " ", 1, -1 );
         mJD  = fields.at( 1 ).toInt();
         q    = fields.at( 2 ).toDouble();
@@ -124,12 +125,9 @@ void AsteroidsComponent::loadData()
         dble_M = fields.at( 8 ).toDouble();
         orbit_id = fields.at( 10 );
         orbit_id.remove( '"' );
-        H = fields.at( 11 ).toDouble();
-        G = fields.at( 12 ).toDouble();
-        if ( fields.at( 13 ) == "Y" )
-            neo = true;
-        else
-            neo = false;
+        H   = fields.at( 11 ).toDouble();
+        G   = fields.at( 12 ).toDouble();
+        neo = fields.at( 13 ) == "Y";
         diameter = fields.at( 16 ).toFloat( &ok );
         if ( !ok ) diameter = 0.0;
         dimensions = fields.at( 17 );
diff --git a/kstars/skycomponents/cometscomponent.cpp b/kstars/skycomponents/cometscomponent.cpp
index d894b61..b0c05f6 100644
--- a/kstars/skycomponents/cometscomponent.cpp
+++ b/kstars/skycomponents/cometscomponent.cpp
@@ -102,11 +102,11 @@ void CometsComponent::loadData() {
         line = fileReader.readLine();
 
         // Ignore comments and too short lines
-        if ( line.at( 0 ) == '#' || line.size() < 8 )
+        if ( line.size() < 8  ||  line.at( 0 ) == '#' )
             continue;
-        
         fields = line.split( "," );
-        //kDebug()<< "No. of Fields:" << fields.count();
+        if( fields.size() < 21 )
+            continue;
 
         name   = fields.at( 0 );
         name   = name.remove( '"' ).trimmed();
@@ -121,10 +121,7 @@ void CometsComponent::loadData() {
         orbit_id = fields.at( 8 );
         orbit_id.remove( '"' );
         
-        if ( fields.at( 9 ) == "Y" )
-            neo = true;
-        else
-            neo = false;
+        neo = fields.at( 9 ) == "Y";
         
         if(fields.at(10).isEmpty())
             M1 = 101.0;        
-- 
1.7.6.3



_______________________________________________
Kstars-devel mailing list
Kstars-devel@kde.org
https://mail.kde.org/mailman/listinfo/kstars-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic