-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
Affects Version/s: None
-
Component/s: None
-
None
-
ALL
This code issue is minor because it is not currently triggered by existing code.
StringBuilder uses a BufBuilder (bson/util/builder.h) to manually manage a char buffer. The default copy constructor and operator= will shallow copy the data pointer, which will ultimately lead to freeing the memory multiple times. You can produce the issue with:
{
StringBuffer a;
// b d'tor frees b.data, which == a.data
// c d'tor frees a.data again
} // a d'tor frees a.data again