Index: include/Vect.h
===================================================================
--- include/Vect.h	(revision 34155)
+++ include/Vect.h	(working copy)
@@ -25,8 +25,7 @@
 int Vect_destroy_line_struct(struct line_pnts *);
 int Vect_point_on_line(struct line_pnts *, double, double *, double *,
 		       double *, double *, double *);
-int Vect_line_segment(struct line_pnts *, double, double,
-		      struct line_pnts *);
+int Vect_line_segment(struct line_pnts *, double, double, struct line_pnts *);
 double Vect_line_length(struct line_pnts *);
 double Vect_area_perimeter(struct line_pnts *);
 double Vect_line_geodesic_length(struct line_pnts *);
@@ -71,8 +70,7 @@
 struct dblinks *Vect_new_dblinks_struct(void);
 void Vect_reset_dblinks(struct dblinks *);
 int Vect_add_dblink(struct dblinks *, int, const char *,
-		    const char *, const char *, const char *,
-		    const char *);
+		    const char *, const char *, const char *, const char *);
 int Vect_check_dblink(struct dblinks *, int);
 int Vect_map_add_dblink(struct Map_info *, int, const char *,
 			const char *, const char *, const char *,
@@ -84,7 +82,7 @@
 struct field_info *Vect_default_field_info(struct Map_info *, int,
 					   const char *, int);
 struct field_info *Vect_get_dblink(struct Map_info *, int);
-struct field_info *Vect_get_field(struct Map_info *, int );
+struct field_info *Vect_get_field(struct Map_info *, int);
 void Vect_set_db_updated(struct Map_info *);
 const char *Vect_get_column_names(struct Map_info *, int);
 const char *Vect_get_column_types(struct Map_info *, int);
@@ -328,8 +326,7 @@
 		 int, struct Map_info *);
 int Vect_overlay_and(struct Map_info *, int, struct ilist *,
 		     struct ilist *, struct Map_info *, int,
-		     struct ilist *, struct ilist *,
-		     struct Map_info *);
+		     struct ilist *, struct ilist *, struct Map_info *);
 
 /* Graph */
 void Vect_graph_init(GRAPH *, int);
@@ -376,6 +373,8 @@
 			   struct line_pnts ***, struct line_pnts ***, int *,
 			   int *, int);
 int Vect_line_check_intersection(struct line_pnts *, struct line_pnts *, int);
+int Vect_line_get_intersections(struct line_pnts *, struct line_pnts *,
+				struct line_pnts *, int);
 char *Vect_subst_var(const char *str, struct Map_info *Map);
 
 /*
Index: lib/vector/Vlib/intersect.c
===================================================================
--- lib/vector/Vlib/intersect.c	(revision 34155)
+++ lib/vector/Vlib/intersect.c	(working copy)
@@ -1065,7 +1065,7 @@
     return 1;
 }
 
-static struct line_pnts *APnts, *BPnts;
+static struct line_pnts *APnts, *BPnts, *IPnts;
 
 static int cross_found;		/* set by find_cross() */
 
@@ -1087,6 +1087,23 @@
 				    BPnts->y[j + 1], BPnts->z[j + 1], &x1,
 				    &y1, &z1, &x2, &y2, &z2, 0);
 
+    switch (ret) {
+    case 0:
+    case 5:
+	break;
+    case 1:
+	if (0 > Vect_copy_xyz_to_pnts(IPnts, &x1, &y1, &z1, 1))
+	    G_warning(_("Error while adding point to array. Out of memory"));
+	break;
+    case 2:
+    case 3:
+    case 4:
+	if (0 > Vect_copy_xyz_to_pnts(IPnts, &x1, &y1, &z1, 1))
+	    G_warning(_("Error while adding point to array. Out of memory"));
+	if (0 > Vect_copy_xyz_to_pnts(IPnts, &x2, &y2, &z2, 1))
+	    G_warning(_("Error while adding point to array. Out of memory"));
+	break;
+    }
     /* add ALL (including end points and duplicates), clean later */
     if (ret > 0) {
 	cross_found = 1;
@@ -1126,11 +1143,21 @@
     if (APoints->n_points == 1 && BPoints->n_points == 1) {
 	if (APoints->x[0] == BPoints->x[0] && APoints->y[0] == BPoints->y[0]) {
 	    if (!with_z) {
+		if (0 >
+		    Vect_copy_xyz_to_pnts(IPnts, &APoints->x[0],
+					  &APoints->y[0], NULL, 1))
+		    G_warning(_("Error while adding point to array. Out of memory"));
 		return 1;
 	    }
 	    else {
-		if (APoints->z[0] == BPoints->z[0])
+		if (APoints->z[0] == BPoints->z[0]) {
+		    if (0 >
+			Vect_copy_xyz_to_pnts(IPnts, &APoints->x[0],
+					      &APoints->y[0], &APoints->z[0],
+					      1))
+			G_warning(_("Error while adding point to array. Out of memory"));
 		    return 1;
+		}
 		else
 		    return 0;
 	    }
@@ -1146,6 +1173,10 @@
 			   NULL, NULL);
 
 	if (dist <= rethresh) {
+	    if (0 >
+		Vect_copy_xyz_to_pnts(IPnts, &APoints->x[0], &APoints->y[0],
+				      &APoints->z[0], 1))
+		G_warning(_("Error while adding point to array. Out of memory"));
 	    return 1;
 	}
 	else {
@@ -1158,8 +1189,13 @@
 			   BPoints->z[0], with_z, NULL, NULL, NULL, &dist,
 			   NULL, NULL);
 
-	if (dist <= rethresh)
+	if (dist <= rethresh) {
+	    if (0 >
+		Vect_copy_xyz_to_pnts(IPnts, &BPoints->x[0], &BPoints->y[0],
+				      &BPoints->z[0], 1))
+		G_warning(_("Error while adding point to array. Out of memory"));
 	    return 1;
+	}
 	else
 	    return 0;
     }
@@ -1246,3 +1282,29 @@
 
     return cross_found;
 }
+
+/*!
+ * \brief Get 2 lines intersection points.
+ * 
+ * A wrapper around Vect_line_check_intersection() function.
+ *
+ * \param[in] APoints first input line 
+ * \param[in] BPoints second input line 
+ * \param[out] IPoints output with intersection points
+ * \param[in] with_z 3D, not supported (only if one or both are points)!
+ *
+ * \return 0 no intersection 
+ * \return 1 intersection found
+ */
+int
+Vect_line_get_intersections(struct line_pnts *APoints,
+			    struct line_pnts *BPoints,
+			    struct line_pnts *IPoints, int with_z)
+{
+    int ret;
+
+    IPnts = IPoints;
+    ret = Vect_line_check_intersection(APoints, BPoints, with_z);
+
+    return ret;
+}

