r13663 tlsa - /trunk/libdom/src/core/element.c

netsurf at semichrome.net netsurf at semichrome.net
Sun Mar 25 11:13:44 BST 2012


Author: tlsa
Date: Sun Mar 25 05:13:44 2012
New Revision: 13663

URL: http://source.netsurf-browser.org?rev=13663&view=rev
Log:
Take copy of classes array, for client to free.

Modified:
    trunk/libdom/src/core/element.c

Modified: trunk/libdom/src/core/element.c
URL: http://source.netsurf-browser.org/trunk/libdom/src/core/element.c?rev=13663&r1=13662&r2=13663&view=diff
==============================================================================
--- trunk/libdom/src/core/element.c (original)
+++ trunk/libdom/src/core/element.c Sun Mar 25 05:13:44 2012
@@ -1155,8 +1155,17 @@
 dom_exception _dom_element_get_classes(struct dom_element *element,
 		lwc_string ***classes, uint32_t *n_classes)
 {
-	*classes = element->classes;
-	*n_classes = element->n_classes;
+	if (element->n_classes > 0) {
+		uint32_t classnr;
+		*n_classes = element->n_classes;
+		*classes = malloc(sizeof(lwc_string *) * element->n_classes);
+		for (classnr = 0; classnr < element->n_classes; ++classnr)
+			*classes[classnr] = lwc_string_ref(
+					element->classes[classnr]);
+	} else {
+		*n_classes = 0;
+		*classes = NULL;
+	}
 
 	return DOM_NO_ERR;
 }




More information about the netsurf-commits mailing list