Correct NULL pointer dereference error in a exception safe manner.

Mon, 15 Dec 2008 15:16:37 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 15 Dec 2008 15:16:37 +0100
changeset 10
579d467531cc
parent 9
0647b688d973
child 11
d926203bd2a8

Correct NULL pointer dereference error in a exception safe manner.

as_dataop.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/as_dataop.cpp	Mon Dec 15 12:46:00 2008 +0100
     1.2 +++ b/as_dataop.cpp	Mon Dec 15 15:16:37 2008 +0100
     1.3 @@ -455,25 +455,25 @@
     1.4  const bool Titraqform::validateData(QFile &Filin) const
     1.5  {
     1.6      QString Firstline;      // Will contain the first line of text
     1.7 -    char *pReadline;        // Contains the read line of text file
     1.8 +    char szReadline[QString(TITRAQ_DATAPATTERN).length() + 4L];  // File line
     1.9      bool bRet = false;      // Set the initial return value
    1.10  
    1.11      if (Filin.isOpen()) {   // Check open state of file
    1.12          Filin.flush();      // Not sure if this is needed
    1.13          Filin.reset();      // Set the file index position to 0
    1.14 -        Filin.readLine(pReadline, QString(TITRAQ_DATAPATTERN).length() + 2L);
    1.15 +        Filin.readLine(szReadline, QString(TITRAQ_DATAPATTERN).length() + 2L);
    1.16      }
    1.17      else {
    1.18          if (!Filin.open(QIODevice::ReadOnly))   // Try to open file
    1.19              throw Genexcept(trUtf8(TITRAQ_READPFILFAIL));
    1.20          else {                          // File is now open
    1.21 -            Filin.readLine(pReadline, QString(TITRAQ_DATAPATTERN).length() + 2L);
    1.22 +            Filin.readLine(szReadline, QString(TITRAQ_DATAPATTERN).length() + 2L);
    1.23              Filin.close();              // Remember to close
    1.24          }
    1.25      }
    1.26  
    1.27      try {   // Pass off to worker method
    1.28 -        Firstline = QString::fromAscii(pReadline);
    1.29 +        Firstline = QString::fromAscii(szReadline);
    1.30          bRet = this->validateData(Firstline);
    1.31      }
    1.32      catch (Genexcept &) {

mercurial