[PATCH] Fix 53360 - String leak in DCOPClient
Luis Pedro Coelho
luis_pedro at netcabo.pt
Sat Mar 8 23:55:05 GMT 2003
Le Samedi 8 Mars 2003 23:46, Ravikiran Rajagopal a écrit :
> Hello,
> The following patch fixes bug 53360 for me. However, I am not familiar
> with the internals of DCOPClient; it is possible that this patch is
> unnecessary (in which case it is harmless). Is it ok to commit? On a
> related note, is it ok to send messages like this (regarding kdelibs fixes)
> to kde-core-devel or should I use kde-devel for this?
>
> Thanks,
> Ravi
>
> Index: dcopclient.cpp
> ===================================================================
> RCS file: /home/kde/kdelibs/dcop/dcopclient.cpp,v
> retrieving revision 1.156
> diff -u -p -r1.156 dcopclient.cpp
> - --- dcopclient.cpp 11 Feb 2003 15:55:56 -0000 1.156
> +++ dcopclient.cpp 8 Mar 2003 22:29:00 -0000
> @@ -502,6 +502,8 @@ DCOPClient::DCOPClient()
> d->qt_bridge_enabled = true;
> d->transactionList = 0L;
> d->transactionId = 0;
> + d->vendor = 0L;
> + d->release = 0L;
> QObject::connect( &d->postMessageTimer, SIGNAL( timeout() ), this,
> SLOT( processPostedMessagesInternal() ) );
>
> if ( !mainClient() )
> @@ -517,6 +519,11 @@ DCOPClient::~DCOPClient()
> if (d->registered)
> unregisterLocalClient( d->appId );
>
> + if (d->vendor)
> + free(d->vendor);
> + if (d->release)
> + free(d->release);
> +
> delete d->notifier;
> delete d->transactionList;
> delete d;
Are you working with HEAD?
The patch is against CVS HEAD, but it seems unnecessary given coolo's commit
on 11 Feb which is almost the same as yours.
Why do we even have DCOPClientPrivate::vendor and DCOPClientPrivate::release
anyway? I propose the following patch:
Index: dcopclient.cpp
===================================================================
RCS file: /home/kde/kdelibs/dcop/dcopclient.cpp,v
retrieving revision 1.157
diff -u -3 -p -r1.157 dcopclient.cpp
--- dcopclient.cpp 6 Mar 2003 18:02:05 -0000 1.157
+++ dcopclient.cpp 8 Mar 2003 23:34:10 -0000
@@ -129,7 +129,6 @@ public:
int majorOpcode; // major opcode negotiated w/server and used to tag all
comms.
int majorVersion, minorVersion; // protocol versions negotiated w/server
- char *vendor, *release; // information from server
static const char* serverAddr; // location of server in ICE-friendly
format.
QSocketNotifier *notifier;
@@ -690,18 +689,15 @@ bool DCOPClient::attachInternal( bool re
IceSetShutdownNegotiation(d->iceConn, False);
int setupstat;
+ const char* vendor = 0;
+ const char* release = 0;
setupstat = IceProtocolSetup(d->iceConn, d->majorOpcode,
static_cast<IcePointer>(d),
False, /* must authenticate */
&(d->majorVersion), &(d->minorVersion),
- &(d->vendor), &(d->release), 1024, errBuf);
-
- if (d->vendor)
- free(d->vendor);
- d->vendor = 0;
- if (d->release)
- free(d->release);
- d->release = 0;
+ &(vendor), &(release), 1024, errBuf);
+ free(vendor);
+ free(release);
if (setupstat == IceProtocolSetupFailure ||
setupstat == IceProtocolSetupIOError) {
hth,
--
Luis Pedro Coelho
check out my game of hearts for the KDE at
http://hearts.sf.net
More information about the kde-core-devel
mailing list