mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	| testplan.cpp had a subtle bug since converting from a fixed-size
cylinder table to a dynamic cylinder table.
As noted in equipment.h, pointers to cylinders are *not* stable
when the cylinder table grows. Therefore, a construct such as
        cylinder_t *cyl0 = get_or_create_cylinder(&dive, 0);
        cylinder_t *cyl1 = get_or_create_cylinder(&dive, 1);
        cylinder_t *cyl2 = get_or_create_cylinder(&dive, 2);
can give dangling cyl0 and cyl1 pointers. This was not an issue
with the old table code, since it had a rather liberal allocation
pattern. However, when switching to std::vector<>, the problem
becomes active.
To "fix" this, simply access the highest index first. Of course,
this should never be done in real code! Therefore, add a
comment at each instance.
Quickly checked all other get_or_create_cylinder() calls and
they seemed to be safe.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | ||
|---|---|---|
| .. | ||
| .gitignore | ||
| CMakeLists.txt | ||
| testAirPressure.cpp | ||
| testAirPressure.h | ||
| testdivesiteduplication.cpp | ||
| testdivesiteduplication.h | ||
| testformatDiveGasString.cpp | ||
| testformatDiveGasString.h | ||
| testgitstorage.cpp | ||
| testgitstorage.h | ||
| testgpscoords.cpp | ||
| testgpscoords.h | ||
| testhelper.cpp | ||
| testhelper.h | ||
| testmerge.cpp | ||
| testmerge.h | ||
| testparse.cpp | ||
| testparse.h | ||
| testparseperformance.cpp | ||
| testparseperformance.h | ||
| testpicture.cpp | ||
| testpicture.h | ||
| testplan.cpp | ||
| testplan.h | ||
| testplannershared.cpp | ||
| testplannershared.h | ||
| testprofile.cpp | ||
| testprofile.h | ||
| testqml.cpp | ||
| testqml.h | ||
| testqPrefCloudStorage.cpp | ||
| testqPrefCloudStorage.h | ||
| testqPrefDisplay.cpp | ||
| testqPrefDisplay.h | ||
| testqPrefDiveComputer.cpp | ||
| testqPrefDiveComputer.h | ||
| testqPrefDivePlanner.cpp | ||
| testqPrefDivePlanner.h | ||
| testqPrefEquipment.cpp | ||
| testqPrefEquipment.h | ||
| testqPrefGeneral.cpp | ||
| testqPrefGeneral.h | ||
| testqPrefGeocoding.cpp | ||
| testqPrefGeocoding.h | ||
| testqPrefLanguage.cpp | ||
| testqPrefLanguage.h | ||
| testqPrefLog.cpp | ||
| testqPrefLog.h | ||
| testqPrefMedia.cpp | ||
| testqPrefMedia.h | ||
| testqPrefPartialPressureGas.cpp | ||
| testqPrefPartialPressureGas.h | ||
| testqPrefProxy.cpp | ||
| testqPrefProxy.h | ||
| testqPrefTechnicalDetails.cpp | ||
| testqPrefTechnicalDetails.h | ||
| testqPrefUnits.cpp | ||
| testqPrefUnits.h | ||
| testqPrefUpdateManager.cpp | ||
| testqPrefUpdateManager.h | ||
| testrenumber.cpp | ||
| testrenumber.h | ||
| testtaglist.cpp | ||
| testtaglist.h | ||
| testunitconversion.cpp | ||
| testunitconversion.h | ||
| tst_qPrefCloudStorage.qml | ||
| tst_qPrefDisplay.qml | ||
| tst_qPrefDiveComputer.qml | ||
| tst_qPrefDivePlanner.qml | ||
| tst_qPrefGeneral.qml | ||
| tst_qPrefGeocoding.qml | ||
| tst_qPrefLanguage.qml | ||
| tst_qPrefPartialPressureGas.qml | ||
| tst_qPrefProxy.qml | ||
| tst_qPrefTechnicalDetails.qml | ||
| tst_qPrefUnits.qml | ||
| tst_qPrefUpdateManager.qml | ||