Re: XForms: problems with fl_get_choice_text

Bjoern Fuerst (fuerst@kph.uni-mainz.de)
Fri, 07 Nov 1997 10:21:45 +0100 (CET)

To subscribers of the xforms list from Bjoern Fuerst <fuerst@kph.uni-mainz.de> :

On 06-Nov-97 Steve Lamont wrote:
>To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :
>

sscanf((char *)datum(),"%*s %s %d %s %d",monat,&tag,time_string,&jahr);

>Bingo!
>
>Is the pointer `time_string' initialized? If not, you're going to be
>writing into who knows where. sscanf() does not do any memory
>allocation, it simply returns data to where ever it thinks it's told
>to write. If `time_string' isn't initialized, then it will have
>whatever value just happens to be on the stack in that slot.
>
>You should change your code to read
>
> char *time_string;
>
> [...]
>
> time_string = ( char *) malloc( TIME_STRING_SIZE );
>
> [...]
>
> sscanf( ... );
>
>where TIME_STRING_SIZE is whatever size is appropriate -- maybe 9?

You are right Steve. Sorry I forgot to write it in the mail (it's my first maili
ng list, but I hope I'm improving).

It is initialized via:

time_string=(char *)malloc(sizeof(char)*10);

Regards

Bjoern
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/