Code

Fixing a possible segfault in the sbasis to path code (also committed to 2geom))
authormgsloan <mgsloan@users.sourceforge.net>
Sat, 18 Aug 2007 02:17:00 +0000 (02:17 +0000)
committermgsloan <mgsloan@users.sourceforge.net>
Sat, 18 Aug 2007 02:17:00 +0000 (02:17 +0000)
src/2geom/sbasis-to-bezier.cpp
src/live_effects/n-art-bpath-2geom.cpp

index 731680075cdfb180679e59af45e9b88b58abb82a..e823b29cac16a411a630fefa80faf10f6fae4cd5 100644 (file)
@@ -172,17 +172,19 @@ void build_from_sbasis(Geom::PathBuilder &pb, D2<SBasis> const &B, double tol) {
     }
 }
 
-void
-path_from_sbasis(Geom::Path &p, D2<SBasis> const &B, double tol) {
+Path
+path_from_sbasis(D2<SBasis> const &B, double tol) {
     PathBuilder pb;
     pb.moveTo(B.at0());
     build_from_sbasis(pb, B, tol);
-    p = pb.peek().front();
+    pb.finish();
+    return pb.peek().front();
 }
 
 //TODO: some of this logic should be lifted into svg-path
 std::vector<Geom::Path>
 path_from_piecewise(Geom::Piecewise<Geom::D2<Geom::SBasis> > const &B, double tol) {
+
     Geom::PathBuilder pb;
     if(B.size() == 0) return pb.peek();
     Geom::Point start = B[0].at0();
@@ -206,6 +208,7 @@ path_from_piecewise(Geom::Piecewise<Geom::D2<Geom::SBasis> > const &B, double to
         }
         build_from_sbasis(pb, B[i], tol);
     }
+    pb.finish();
     return pb.peek();
 }
 
index 5f4e4c7b90af59a4c8882822f360299cc31af866..e71e28b991fd4cb565e125e01f747b5a7a023bcb 100644 (file)
@@ -45,8 +45,7 @@ static void curve_to_svgd(std::ostream & f, Geom::Curve const* c) {
 //    }\r
     else { \r
         //this case handles sbasis as well as all other curve types\r
-        Geom::Path sbasis_path;\r
-        path_from_sbasis(sbasis_path, c->sbasis(), 0.1);\r
+        Geom::Path sbasis_path = path_from_sbasis(sbasis_path, c->sbasis(), 0.1);\r
 \r
         //recurse to convert the new path resulting from the sbasis to svgd\r
         for(Geom::Path::iterator iter = sbasis_path.begin(); iter != sbasis_path.end(); ++iter) {\r