home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!olivea!sgigate!odin!mikey
- From: mikey@sgi.com (Mike Yang)
- Newsgroups: comp.sys.sgi.graphics
- Subject: Re: motif text widgets
- Message-ID: <1993Jan13.043350.16975@odin.corp.sgi.com>
- Date: 13 Jan 93 04:33:50 GMT
- References: <1993Jan13.040941.4854@vela.acs.oakland.edu>
- Sender: news@odin.corp.sgi.com (Net News)
- Distribution: na
- Organization: Silicon Graphics, Inc.
- Lines: 32
- Nntp-Posting-Host: eukanuba.wpd.sgi.com
-
- In article <1993Jan13.040941.4854@vela.acs.oakland.edu> sglanger@vela.acs.oakland.edu (LANGER STEVEN C) writes:
- >void cbfunc (Widget w, XtPointer data, XtPointer dummy)
- >{
- > char *text;
- > char str[]="here i am";
- >
- > if (strcasecmp(data, "b1") == 0)
- > {
- > temp = XtMalloc (sizeof(str));
- > temp[sizeof(str)] = 0 ; /* null terminator */
- > XmTextSetString (w, text);
- > XtFree (text);
- > }
- >
- >}
-
- The variable text is uninitialized. Did you want to say:
-
- XmTextSetString (w, temp);
-
- instead?
-
- Also, your null terminator is past the bounds of the array you allocate.
- You probably want:
-
- temp[sizeof(str)-1] = '\0';
-
- instead.
-
- -----------------------------------------------------------------------
- Mike Yang Silicon Graphics, Inc.
- mikey@sgi.com 415/390-1786
-