Article View: comp.sys.sgi.graphics
Article #108Re: motif text widgets
From: Mike Yang
Date: Wed, 13 Jan 1993 04:33
Date: Wed, 13 Jan 1993 04:33
32 lines
1295 bytes
1295 bytes
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
Technical Details
Message-ID:
<1993Jan13.043350.16975@odin.corp.sgi.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!olivea!sgigate!odin!mikeyReferences:
<1993Jan13.040941.4854@vela.acs.oakland.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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