diff options
author | Qiu-Yuan (Kathleen) Yang <qiu-yuan.yang@sun.com> | 2006-09-01 18:04:26 -0700 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@sun.com> | 2006-09-01 18:04:26 -0700 |
commit | b54d069ea397486c6125943ffdb813482383576a (patch) | |
tree | 779d99642902c071b4d18f4a8ed4e91d59321a5a | |
parent | 6e48adfab0c020ab5d55b68f9b4cc63ed5d8b14c (diff) |
Sun bug #4962001: Close memory leaks seen in Motif apps
The function "GetResources" will return a copy of resources to the caller
and the caller has the responsibility to free the returned copy. However some
functions, such as "XtGetSubresources", "_XtGetResources", and
"XtGetApplicationResources" invoked "GetResources" without freeing the
returned resource copy.
-rw-r--r-- | src/Resources.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Resources.c b/src/Resources.c index 7da7d90..8e56b86 100644 --- a/src/Resources.c +++ b/src/Resources.c @@ -1031,7 +1031,7 @@ XtCacheRef *_XtGetResources( XrmQuarkList quark_args; WidgetClass wc; ConstraintWidgetClass cwc; - XtCacheRef *cache_refs; + XtCacheRef *cache_refs, *cache_refs_core; Cardinal count; wc = XtClass(w); @@ -1057,10 +1057,14 @@ XtCacheRef *_XtGetResources( if (w->core.constraints != NULL) { cwc = (ConstraintWidgetClass) XtClass(w->core.parent); - (void) GetResources(w, (char*)w->core.constraints, names, classes, + cache_refs_core = + GetResources(w, (char*)w->core.constraints, names, classes, (XrmResourceList *) cwc->constraint_class.resources, cwc->constraint_class.num_resources, quark_args, args, num_args, typed_args, num_typed_args, False); + if (cache_refs_core) { + XtFree((char *)cache_refs_core); + } } FreeCache(quark_cache, quark_args); UNLOCK_PROCESS; @@ -1088,6 +1092,7 @@ void _XtGetSubresources ( XrmQuarkList quark_args; XrmResourceList* table; Cardinal count, ntyped_args = num_typed_args; + XtCacheRef *Resrc = NULL; WIDGET_TO_APPCON(w); if (num_resources == 0) return; @@ -1117,11 +1122,12 @@ void _XtGetSubresources ( XrmCompileResourceListEphem(resources, num_resources); } table = _XtCreateIndirectionTable(resources, num_resources); - (void) GetResources(w, (char*)base, names, classes, table, num_resources, + Resrc = GetResources(w, (char*)base, names, classes, table, num_resources, quark_args, args, num_args, typed_args, &ntyped_args, False); FreeCache(quark_cache, quark_args); XtFree((char *)table); + XtFree((char *)Resrc); XtStackFree((XtPointer)names, names_s); XtStackFree((XtPointer)classes, classes_s); UNLOCK_APP(app); @@ -1160,6 +1166,7 @@ void _XtGetApplicationResources ( #ifdef XTHREADS XtAppContext app; #endif + XtCacheRef *Resrc = NULL; if (num_resources == 0) return; @@ -1206,11 +1213,12 @@ void _XtGetApplicationResources ( } table = _XtCreateIndirectionTable(resources,num_resources); - (void) GetResources(w, (char*)base, names, classes, table, num_resources, + Resrc = GetResources(w, (char*)base, names, classes, table, num_resources, quark_args, args, num_args, typed_args, &ntyped_args, False); FreeCache(quark_cache, quark_args); XtFree((char *)table); + XtFree((char *)Resrc); if (w != NULL) { XtStackFree((XtPointer)names, names_s); XtStackFree((XtPointer)classes, classes_s); |