uClibc++ memleak

Thomas Volpini e9825746 at student.tuwien.ac.at
Fri Aug 11 09:12:17 UTC 2006


Hello,

I've found a memleak in uClibc++'s vector, you can find a test program and the
fix below. I'm not sure if there are similar issues in other classes.

Regards,
Thomas



#include <vector>

struct foo {
  std::vector<int> bar;

  ~foo() {
    printf("dtor\n");
  }
};

int main() {

  std::vector<struct foo> v1;

  foo f1;
  f1.bar.push_back(1);

  v1.push_back(f1);
  v1.push_back(f1);
  v1.push_back(f1);

  v1.clear();

  return 0;
}






Index: include/vector
===================================================================
--- include/vector      (revision 1243)
+++ include/vector      (revision 1244)
@@ -348,7 +348,7 @@
                }

                _UCXXEXPORT void clear(){
-                       elements = 0;
+                       downsize(0);
                }





More information about the uClibc mailing list