[GRASS5] SegFault in Vect_New_line_struct()

Michel Wurtz - ENGEES/CEREG mw at engees.u-strasbg.fr
Wed Jul 26 10:44:29 EDT 2000


David D Gray wrote:
> 
> spijker at geo.uu.nl wrote:
> Almost always an unexpected bomb-out in malloc() or free() is the result
> of a delayed memory allocation problem. So, not likely anything to do
> with Vect__new_line_struct().
> 
> A likely candidate is m.in.e00/vector.c lines 107, 109, ..., where the
> x,y arrays overflow by 1 * sizeof(double).

AAARGH! You're right : when the coverage is in single precision and the
number of points is odd, odd things may occur in vector.c :-))

Lines 92,93 are the best candidates for this.  Here is a quick bug fix.
Markus, can you insert it before the new release ? I am not on the good
machine for cvs upload.

------------------start of patch

*** vector.c    Wed Jul 26 16:36:12 2000
--- vector.c~   Wed Jul 26 16:32:06 2000
***************
*** 59,66 ****
        }
        if (debug > 4)
            fprintf( fdlog, "line %d (%d pnts) id=%d\n", j, npts, covnum);
!       x = (double *)G_malloc( sizeof(double) * (npts+1));
!       y = (double *)G_malloc( sizeof(double) * (npts+1));
 
        if (prec) {     /* double precision : 1 coord pair / line */
            for (i = 0; i < npts; i++) {
--- 59,66 ----
        }
        if (debug > 4)
            fprintf( fdlog, "line %d (%d pnts) id=%d\n", j, npts, covnum);
!       x = (double *)G_malloc( sizeof(double) * npts);
!       y = (double *)G_malloc( sizeof(double) * npts);
 
        if (prec) {     /* double precision : 1 coord pair / line */
            for (i = 0; i < npts; i++) {

--------------------------- end of patch --------

-- 
Michel Wurtz    ENGEES - CEREG
                1, quai Koch - BP 1039, F-67070 STRASBOURG cedex
                Tel: +33 03.88.24.82.45  Fax: +33 03.88.37.04.97

---------------------------------------- 
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo at geog.uni-hannover.de with
subject 'unsubscribe grass5'



More information about the grass-dev mailing list