[kmobiletools] KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools

Allen Winter winter at kde.org
Wed Jun 20 20:44:44 CEST 2007


On Wednesday 20 June 2007 1:35:07 pm Dirk Mueller wrote:
> SVN commit 678094 by mueller:
> 
> fix memory leak (CID 3649)
> 
> 
>  M  +4 -5      serialdevice.cpp  
> 
> 
> --- trunk/KDE/kdepim/kmobiletools/kmobiletools/libkmobiletools/serialdevice.cpp #678093:678094
> @@ -396,18 +396,18 @@
>      kDebug() << "gotData() : got "<< availData << "bytes to read" << endl;
>  if(!availData) availData=MAXBUFSIZE; // fix for rfcomm wrong size
>  //     kDebug() << "GotData: Size=" << availData << endl;
> -    char *buffer=new char [availData+1];
> -    memset(buffer, 0, availData+1);
> +    QByteArray buffer( availData+1, 0 );
>      int readdata;
>  #ifdef KBLUETOOTH
>      if(d->bluetooth)
> -    readdata=d->rfcomm->read(buffer, availData);
> +    readdata=d->rfcomm->read(buffer.data(), availData);
>  #endif
> -    readdata=d->serial->read(buffer, availData);
> +    readdata=d->serial->read(buffer.data(), availData);
>      if(readdata==-1)
>      {
>          kDebug() << "Read error: closing device link\n";
>          close();
> +        delete []
^^ does not compile for me.  and not just because of the missing semicolon.


>          return;
>      }
>      if(readdata>0)
> @@ -417,7 +417,6 @@
>          d->gotData=availData;
>  //         std::cout << QString(buffer).replace("\r", "\n").replace("\n\n", "\n");
>      }
> -    delete [] buffer;
>  }
>  
>  
>


More information about the kmobiletools mailing list