Tim,
> Okay - I've fixed the problem with convert on amd64 (I think).
>
> The problem occurs when NATIVE encoded FITS header is converted using
> FITS2NDF. It seems (for some reason unknown to me) to go through the DSS
> parser
This happens if you do not specify an encoding when running fits2ndf. In
this case fits2ndf has to decide for itself which encoding to use, and to
do this it needs to know which encodings are present in the header,
because in practice a header sometimes contains more than one encoding.
It does this by attempting to read an object from the header using each of
the supported encodings (including DSS) in turn.
I've made a fix to DSSToStore which has the same effect as as your
suggestion and committed it to CVS.
Thanks for tracking this down.
David
> and hits the following code in DSSToStore in fitschan.c:
>
> char *text; /* Pointer to textual keyword value */
>
> ...
>
> /* Copy the first 10 non-blank characters from the PLTDECSN keyword. */
> GetValue( this, "PLTDECSN", AST__STRING, &text, 1, 1, method, class );
> text += strspn( text, " " );
> text[ strcspn( text, " " ) ] = 0;
> strncpy( pltdecsn, text, 10 );
>
> Valgrind complains here about the invalid read of an uninitialised value.
> Initialising the pointer to NULL:
>
> char * text = NULL;
>
> gives a more explicit error in the line after GetValue because now
> you get a segv on all platforms (including 32bit linux) by trying to
> address a null pointer in the line after GetValue.
>
> The fix is to initialise the pointer to NULL and then either check
> the return value from GetValue to see if the fits item was found,
> or simply check to see if text is still NULL.
>
> Every other use of GetValue in connection with AST__STRING is written like
> this:
>
> if (GetValue( this, "PLTDECSN", AST__STRING, &text, 1, 1, method, class )) {
> text += strspn( text, " " );
> text[ strcspn( text, " " ) ] = 0;
> strncpy( pltdecsn, text, 10 );
> }
>
> so that might be the most appropriate fix.
>
> --
> Tim Jenness
> JAC software
> http://www.jach.hawaii.edu/~timj
>
|