[Clam-devel] fix use of empty OutControlArray

Pau Arumi parumi at iua.upf.edu
Mon Apr 2 08:48:28 PDT 2007




En/na Zach Welch ha escrit:
> Hi all,
> 
> I found that the following trivial test case causes a bad assert in 
> OutControlArray.  The subsequent "one-line" patch cures the problem.


Yes it was a bug. Thanks for spotting it and give a solution. However,
I've done the fix (already commited) in OutControlArray::Shrink

Pau


Index: CLAM/src/Flow/Controls/OutControlArray.cxx
===================================================================
--- CLAM/src/Flow/Controls/OutControlArray.cxx  (revision 9917)
+++ CLAM/src/Flow/Controls/OutControlArray.cxx  (working copy)
@@ -85,6 +85,7 @@
  void OutControlArray::Shrink(int size)
  {
         int previousSize = mControls.size();
+       if (size==previousSize) return;
         CLAM_ASSERT(size < previousSize, "OutControlArray::Cannot 
Shrink a Control Array to a larger size");
         for (int i = previousSize-1; i >= size; i--) {
                 delete mControls[i];


> Cheers,
> 
> Zach
> 
> % cd ..../clam-bin
> % cat >test.cxx
> #include <CLAM/OutControlArray.hxx>
> int main() { CLAM::OutControlArray array; return 0; }
> % gcc -o test test.cxx -I include -L lib -lclam_core -lclam_processing -ldl
> % LD_LIBRARY_PATH=lib ./test
> ##########################################################
> ################### ASSERTION FAILED #####################
> ##########################################################
> At file core/src/OutControlArray.cxx line 88
> OutControlArray::Cannot Shrink a Control Array to a larger size
> [...snip...]
> Aborted
> 
> 
> Index: CLAM/src/Flow/Controls/OutControlArray.cxx
> ===================================================================
> --- CLAM/src/Flow/Controls/OutControlArray.cxx  (revision 9909)
> +++ CLAM/src/Flow/Controls/OutControlArray.cxx  (working copy)
> @@ -46,7 +46,8 @@
> 
>  OutControlArray::~OutControlArray()
>  {
> -       Shrink(0);
> +       if (mControls.size())
> +               Shrink(0);
>  }
> 
> 
> 
> _______________________________________________
> Clam-devel mailing list
> Clam-devel at llistes.projectes.lafarga.org
> https://llistes.projectes.lafarga.org/cgi-bin/mailman/listinfo/clam-devel





More information about the clam-devel mailing list