There are multiple problems with FontLists in the TextF code.
Grabbing a pointer to the parent's FontList in FontInitialize
is dangerous because the parent might free its copy. A few
lines down in the same function, there is a memory leak due
to the way that _XmGetDefaultFontList returns a copied FontList.
Thepatch below covers both problems.
There is another problem in set_values. The call to
TextF_FontMaxWidth(w) near the bottom of the function
end up looking at TextF_FontList(w) -- which has just
been free'd a few lines eariler in set_values. I wasn't
sure of the best fix, so patch below does not cover this
third problem.
- Steve
*** lesstif-0.91.3/lib/Xm/TextF.c.orig Wed Jun 14 16:00:13 2000
--- lesstif-0.91.3/lib/Xm/TextF.c Wed Jul 19 16:36:58 2000
***************
*** 740,746 ****
XtVaGetValues(parent,
XmNtextFontList, &TextF_FontList(w),
NULL);
! TextF_FontListCreated(w) = False;
break;
}
--- 740,748 ----
XtVaGetValues(parent,
XmNtextFontList, &TextF_FontList(w),
NULL);
! /* Watch out, the parent might free its copy. */
! TextF_FontList(w) = XmFontListCopy(TextF_FontList(w));
! TextF_FontListCreated(w) = True;
break;
}
***************
*** 753,760 ****
{
TextF_FontList(w) = _XmGetDefaultFontList((Widget)w, XmTEXT_FONTLIST);
! /* we didn't create it, so don't free */
! TextF_FontListCreated(w) = False;
}
}
else
--- 755,762 ----
{
TextF_FontList(w) = _XmGetDefaultFontList((Widget)w, XmTEXT_FONTLIST);
! /* _XmGetDefaultFontList has been changed to return a copy. */
! TextF_FontListCreated(w) = True;
}
}
else
--== Sent via Deja.com http://www.deja.com/ ==--
Before you buy.