[Proj] pj_malloc() inits P->es as junk memory

Gerald I. Evenden geraldi.evenden at gmail.com
Sat Aug 15 09:50:56 EST 2009


Three comments:

1. I do not agree with what you are doing because segmenting of Goode is *not* 
a standard

2. It is a graphic operation very easily handled by external scripts.

3. You are using very dated code and a quick check of current proj_init shows 
that es and a host of other variables are initialized *very* early in the 
structure initialization---expecially when compared with the ancient pj 
stuff.  Also pj_alloc is not used anymore and malloc is directly called where 
applicable.

On Friday 14 August 2009 5:40:51 pm David Turover wrote:
> I had semi-random failures in my modified pj_goode (which uses pj_gn_sinu
> and pj_moll) where the results from sinu would come back as inf, inf. In
> these cases, sinu was initialized to use its ellipsoid functions instead
> of its spherical functions.
>
> It seems P->es was not initialized in PJ_gn_sinu.c ENTRY1(sinu, en) where
> P->es is checked to see whether the spherical or ellipsoid functions should
> be used. Every so often, malloc would put memory with nonzero data in
> P->es.
>
> This can be fixed by replacing malloc() with calloc() at pj_alloc.c line
> 20:
>
> 	// void *res = malloc(size);
> 	void *res = (void*) calloc(size, sizeof(void));
>
>
> The random inf problem should happen with the official pj_goode as well.
> I haven't tested it, but I didn't modify it enough that it should matter
> to this issue.
>
> Note: pj_gn_sinu's setup() sets P->es to zero, but that function is not
> called until after P->es is first tested in ENTRY1. It can't be moved
> before the test because that would wipe out any intentional setting of
> P->es to a nonzero value from an outside function that calls ENTRY1 on an
> already allocated sinu object.
>
>  - David T.
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj



-- 
The whole religious complexion of the modern world is due
to the absence from Jerusalem of a lunatic asylum.
-- Havelock Ellis (1859-1939) British psychologist


More information about the Proj mailing list