yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #10961
[Branch ~yade-pkg/yade/git-trunk] Rev 4019: Prevent crash in liqVolIterBody
------------------------------------------------------------
revno: 4019
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Wed 2014-06-11 14:06:47 +0200
message:
Prevent crash in liqVolIterBody
Static function can segfault, if the particle
has no ViscElCapPhys
modified:
pkg/dem/ViscoelasticCapillarPM.cpp
--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'pkg/dem/ViscoelasticCapillarPM.cpp'
--- pkg/dem/ViscoelasticCapillarPM.cpp 2014-05-27 11:24:16 +0000
+++ pkg/dem/ViscoelasticCapillarPM.cpp 2014-06-11 12:06:47 +0000
@@ -531,14 +531,18 @@
Real liqVolIterBody (shared_ptr<Body> b) {
Real LiqVol = 0.0;
- for(Body::MapId2IntrT::iterator it=b->intrs.begin(),end=b->intrs.end(); it!=end; ++it) {
- if(!((*it).second) or !(((*it).second)->isReal())) continue;
- ViscElCapPhys* physT=dynamic_cast<ViscElCapPhys*>(((*it).second)->phys.get());
- if (physT->Vb>0) {
- LiqVol += physT->Vb/2.0;
+ if (!b) {
+ return LiqVol;
+ } else {
+ for(Body::MapId2IntrT::iterator it=b->intrs.begin(),end=b->intrs.end(); it!=end; ++it) {
+ if(!((*it).second) or !(((*it).second)->isReal())) continue;
+ ViscElCapPhys* physT=dynamic_cast<ViscElCapPhys*>(((*it).second)->phys.get());
+ if (physT and physT->Vb and physT->Vb>0) {
+ LiqVol += physT->Vb/2.0;
+ }
}
+ return LiqVol;
}
- return LiqVol;
}
Real LiqControl::liqVolBody (id_t id) const {