hksonngan / mandelbulber

Automatically exported from code.google.com/p/mandelbulber
GNU General Public License v3.0
0 stars 0 forks source link

Using 'memset' on struct that contains a 'std::vector'. #26

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
If found two issues, where memset is used on a struct that contains a 
std::vector. This can be dangerous and can lead to inconsistent memory (see 
discussion at http://bytes.com/topic/c/answers/447117-memset-structs-non-pods).

The locations i was able to identifiy are:
src/Render3D.cpp line 1407 and line 1623

Reference and further reading:
 -http://bytes.com/topic/c/answers/447117-memset-structs-non-pods

Best regards

Martin Ettl 

Original issue reported on code.google.com by ettl.mar...@gmail.com on 16 Nov 2013 at 2:21

GoogleCodeExporter commented 8 years ago
src/Render3D.cpp l: 1407 - memset will be removed - fractParamDefault is filled 
completely later, so doesn't need to be initialized

src/Render3D.cpp l: 1623 - here is memcopy (memcpy(fractParam, 
&noGUIdata.fractparams, sizeof(sParamRender));). This place shouldn't generate 
problems, because   std::vector<enumFractalFormula> formulaSequence and 
std::vector<double> hybridPowerSequence are not changed during run and are only 
read. Even if there will be used the same memory pointers inside vectors this 
will work properly.

What is your opinion?

Original comment by buddhi1...@gmail.com on 17 Nov 2013 at 8:06