Re: [g-a-devel]the maybe leak in libspi/impl_getSelection



On Tue, 2002-08-20 at 12:53, Michael Meeks wrote:
> Hi Bolian,
> 
> On Tue, 2002-08-20 at 11:37, Bolian Yin wrote:
> > I notice that in libspi/text.c :  impl_getSelction,  the return string 
> > of "atk_text_get_selection" is not been used.
> > while in impl_getText (and many other impls), the return string is 
> > copied and freed.  
> > So I wonder, is this designed and the implementation of 
> > "atk_text_get_selection" will take care of it? 
> 
> 	Nope, it's a simple memory leak; we should g_free the result
> immediately since it's not interesting.
> 
> 	Good catch;

Indeed!

Attached is a patch to fix this, which I am now committing to CVS.
(patch also includes minor changes to NEWS and the HACKING patch
previously posted).

Thanks,

-Bill

> 		Michael.
> 
> -- 
>  mmeeks gnu org  <><, Pseudo Engineer, itinerant idiot
> 
> _______________________________________________
> Gnome-accessibility-devel mailing list
> Gnome-accessibility-devel gnome org
> http://mail.gnome.org/mailman/listinfo/gnome-accessibility-devel

? oneway.patch
? diffs.diff
? impldiffs.diff
? current.diffs
? oneway-all.diff
? oneways.diff
? foo
? notes.txt
? mouse-patch.diff
? extensions-to-test-simple.c.diff
? hacking.diff
? at-spi.diff
? cspi/cspi.patch
? cspi/bonobo/diff
? docs/reference/cspi/tmpl/spi_streamable_content.sgml
? docs/reference/cspi/tmpl/at-spi-cspi-unused.sgml
? registryd/at-spi-registryd
? registryd/Accessibility_Registry.server.in
? test/stress-test
? test/event-listener-test
? test/screen-review-test
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/at-spi/ChangeLog,v
retrieving revision 1.236
diff -u -r1.236 ChangeLog
--- ChangeLog	19 Aug 2002 10:18:28 -0000	1.236
+++ ChangeLog	20 Aug 2002 12:33:50 -0000
@@ -1,3 +1,15 @@
+2002-08-20  Bill Haneman <bill haneman sun com>
+
+	* HACKING: 
+	Clarified and reworded our commit policy.
+
+	* NEWS:
+	Started an API "todo" addition list for 2.2.
+
+	* libspi/text.c:
+	(impl_getSelection):
+	Free char pointer from atk_text_get_selection, which was being leaked.
+
 2002-08-19  Bill Haneman <bill haneman sun com>
 
 	* AUTHORS: 
Index: NEWS
===================================================================
RCS file: /cvs/gnome/at-spi/NEWS,v
retrieving revision 1.6
diff -u -r1.6 NEWS
--- NEWS	19 Jun 2002 18:22:45 -0000	1.6
+++ NEWS	20 Aug 2002 12:33:50 -0000
@@ -69,6 +69,24 @@
   returns.
 
 * Made Accessibility_StateSet inherit from BonoboUnknown as it should;
-  this was the main existing breakage in StateSet.
+this was the main existing breakage in StateSet.
+
+
+=================
+
+
+TODO API Additions:
+
+getStateName () and STATE_EXTENDED to allow extension of State API (already 
+in ATK).
+
+AccessibleAction_getType () and AccessibleAction_getTypeName ().
+
+need getBaseAttributes () 
+for AccessibleText (available in ATK I think).
+
+table: getVisibleRange
+
+state: HEADER, etc. for spreadsheet cells
 
 
Index: libspi/text.c
===================================================================
RCS file: /cvs/gnome/at-spi/libspi/text.c,v
retrieving revision 1.14
diff -u -r1.14 text.c
--- libspi/text.c	3 May 2002 22:55:34 -0000	1.14
+++ libspi/text.c	20 Aug 2002 12:33:50 -0000
@@ -324,8 +324,10 @@
   
   g_return_if_fail (text != NULL);
 
-  atk_text_get_selection (text, selectionNum,
-			  &intStartOffset, &intEndOffset);
+  /* atk_text_get_selection returns gchar* which we discard */
+  g_free (atk_text_get_selection (text, selectionNum,
+				  &intStartOffset, &intEndOffset));
+  
   *startOffset = intStartOffset;
   *endOffset = intEndOffset;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]