home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / sgi / graphics / 130 < prev    next >
Encoding:
Internet Message Format  |  1993-01-12  |  1.2 KB

  1. Path: sparky!uunet!spool.mu.edu!olivea!sgigate!odin!mikey
  2. From: mikey@sgi.com (Mike Yang)
  3. Newsgroups: comp.sys.sgi.graphics
  4. Subject: Re: motif text widgets
  5. Message-ID: <1993Jan13.043350.16975@odin.corp.sgi.com>
  6. Date: 13 Jan 93 04:33:50 GMT
  7. References: <1993Jan13.040941.4854@vela.acs.oakland.edu>
  8. Sender: news@odin.corp.sgi.com (Net News)
  9. Distribution: na
  10. Organization: Silicon Graphics, Inc.
  11. Lines: 32
  12. Nntp-Posting-Host: eukanuba.wpd.sgi.com
  13.  
  14. In article <1993Jan13.040941.4854@vela.acs.oakland.edu> sglanger@vela.acs.oakland.edu (LANGER STEVEN C) writes:
  15. >void cbfunc (Widget w, XtPointer data, XtPointer dummy)
  16. >{
  17. >    char *text;
  18. >    char str[]="here i am";
  19. >
  20. >    if (strcasecmp(data, "b1") == 0)
  21. >    {
  22. >        temp = XtMalloc (sizeof(str));
  23. >        temp[sizeof(str)] = 0    ;    /* null terminator */
  24. >        XmTextSetString (w, text);
  25. >        XtFree (text);
  26. >    }
  27. >
  28. >}
  29.  
  30. The variable text is uninitialized.  Did you want to say:
  31.  
  32.     XmTextSetString (w, temp);
  33.  
  34. instead?
  35.  
  36. Also, your null terminator is past the bounds of the array you allocate.
  37. You probably want:
  38.  
  39.     temp[sizeof(str)-1] = '\0';
  40.  
  41. instead.
  42.  
  43. -----------------------------------------------------------------------
  44.                  Mike Yang        Silicon Graphics, Inc.
  45.                mikey@sgi.com           415/390-1786
  46.