From patchwork Tue Nov 22 09:33:05 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Holger Brunn X-Patchwork-Id: 12100 Received: from smtprelay03.ispgateway.de ([80.67.18.15]) by www.linuxtv.org with esmtp (Exim 4.50) id 1EeUWR-0000qc-Hf for vdr@linuxtv.org; Tue, 22 Nov 2005 10:33:07 +0100 Received: (qmail 29162 invoked from network); 22 Nov 2005 09:33:06 -0000 Received: from unknown (HELO localhost.localdomain) (845114@[85.216.19.19]) (envelope-sender ) by smtprelay03.ispgateway.de (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 22 Nov 2005 09:33:06 -0000 Received: from shire.middleearth ([192.168.1.183]) by localhost.localdomain with esmtp (Exim 4.54) id 1EeUWQ-0004Ja-8Z for vdr@linuxtv.org; Tue, 22 Nov 2005 10:33:06 +0100 From: Holger Brunn To: VDR Mailing List Date: Tue, 22 Nov 2005 10:33:05 +0100 User-Agent: KMail/1.8.2 References: <200511202149.54264.lists@magoa.net> <4380E953.7030509@uklinux.net> In-Reply-To: <4380E953.7030509@uklinux.net> MIME-Version: 1.0 Message-Id: <200511221033.05622.holger.brunn@stud.uni-karlsruhe.de> X-SA-Exim-Connect-IP: 192.168.1.183 X-SA-Exim-Mail-From: holger.brunn@stud.uni-karlsruhe.de X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on Lothlorien X-Spam-Level: X-Spam-Status: No, score=-4.3 required=3.5 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.0 Subject: Re: [vdr] Re: cString operator= with same buffer X-SA-Exim-Version: 4.2 (built Fri, 04 Mar 2005 01:30:41 +0100) X-SA-Exim-Scanned: Yes (on localhost.localdomain) X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Nov 2005 09:33:07 -0000 Status: O X-Status: X-Keywords: X-UID: 6298 > I think something should be done to fix the "assign cString to itself" > case, even though this is very unlikely. This does go wrong with the > current code, even with the copy constructor added. Okay, now as all seems to be said, here is a patch that checks for that case (that may happen when working with references/pointers to cStrings), leaving Klaus with the decision whether it's useful to have it or not. Greetings Holger diff -Nu vdr-1.3.36-org/tools.c vdr-1.3.36/tools.c --- vdr-1.3.36-org/tools.c 2005-11-20 12:58:55.000000000 +0100 +++ vdr-1.3.36/tools.c 2005-11-22 10:22:31.000000000 +0100 @@ -539,6 +539,7 @@ cString &cString::operator=(const cString &String) { + if(this==&String) return *this; free(s); s = String.s ? strdup(String.s) : NULL; return *this;