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

List:       kde-commits
Subject:    playground/utils/strigi-chemical/src/alchemy
From:       Egon Willighagen <e.willighagen () science ! ru ! nl>
Date:       2007-11-14 11:50:01
Message-ID: 1195041001.723193.23814.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 736591 by egonw:

Fixed a core dump source: only substr if string is long enough

 M  +3 -2      alchemylineanalyzer.cpp  


--- trunk/playground/utils/strigi-chemical/src/alchemy/alchemylineanalyzer.cpp #736590:736591
@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2007 Jerome Pansanel <j.pansanel@pansanel.net>
  * Copyright (C) 2007 Alexandr Goncearenco <neksa@neksa.net>
+ * Copyright (C) 2007 Egon Willighagen <egonw@users.sf.net>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -55,10 +56,10 @@
     std::string line(data,length);
     ++linecount;
     
-    if (linecount == 1) {
+    if (linecount == 1 && line.length() > 3) {
         atomcount = atoi(line.substr(0,4).c_str()); 
     }
-    else if(linecount <= atomcount) {
+    else if(linecount <= atomcount && line.length() > 16) {
         string element = line.substr(5,12);
         if (m_formula.find(element) != m_formula.end()) {
             m_formula[element] += 1;
[prev in list] [next in list] [prev in thread] [next in thread] 

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