From stdcxx-commits-return-1746-apmail-incubator-stdcxx-commits-archive=incubator.apache.org@incubator.apache.org Mon Sep 17 09:33:21 2007 Return-Path: Delivered-To: apmail-incubator-stdcxx-commits-archive@www.apache.org Received: (qmail 30774 invoked from network); 17 Sep 2007 09:33:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Sep 2007 09:33:20 -0000 Received: (qmail 67385 invoked by uid 500); 17 Sep 2007 09:33:13 -0000 Delivered-To: apmail-incubator-stdcxx-commits-archive@incubator.apache.org Received: (qmail 67363 invoked by uid 500); 17 Sep 2007 09:33:13 -0000 Mailing-List: contact stdcxx-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-commits@incubator.apache.org Received: (qmail 67352 invoked by uid 99); 17 Sep 2007 09:33:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 02:33:12 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 09:35:10 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C78231A9832; Mon, 17 Sep 2007 02:32:57 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r576327 - /incubator/stdcxx/trunk/src/catalog.cpp Date: Mon, 17 Sep 2007 09:32:57 -0000 To: stdcxx-commits@incubator.apache.org From: faridz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070917093257.C78231A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: faridz Date: Mon Sep 17 02:32:53 2007 New Revision: 576327 URL: http://svn.apache.org/viewvc?rev=576327&view=rev Log: 2007-09-17 Farid Zaripov * catalog.cpp (__catfind): Fixed undefined behavior when __rw_catlist vector is full and id is not valid. Modified: incubator/stdcxx/trunk/src/catalog.cpp Modified: incubator/stdcxx/trunk/src/catalog.cpp URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/src/catalog.cpp?rev=576327&r1=576326&r2=576327&view=diff ============================================================================== --- incubator/stdcxx/trunk/src/catalog.cpp (original) +++ incubator/stdcxx/trunk/src/catalog.cpp Mon Sep 17 02:32:53 2007 @@ -71,12 +71,14 @@ CatVector::size_type __catfind(nl_catd id) { - CatVector::size_type i = 0; - while (i < __rw_catlist.size() && __rw_catlist[i] && __rw_catlist[i]->id() != id) - i++; - if (!__rw_catlist[i]) - return __rw_catlist.size(); - return i; + for (CatVector::size_type i = 0; + i < __rw_catlist.size() && __rw_catlist[i]; ++i) { + + if (__rw_catlist[i]->id() == id) + return i; + } + + return __rw_catlist.size(); }