fix-calloc-args.patch (1,963 bytes)
2025-01-09 09:31
Description: fix transposed calloc args
Author: أحمد المحمودي (Ahmed El-Mahmoudy) <aelmahmoudy@users.sourceforge.net>
Bug: https://bugs.netsurf-browser.org/mantis/view.php?id=2885
Forwarded: https://bugs.netsurf-browser.org/mantis/file_download.php?file_id=751&type=bug
Index: libdom/bindings/xml/expat_xmlparser.c
===================================================================
--- libdom.orig/bindings/xml/expat_xmlparser.c 2025-01-09 09:03:48.883278479 +0100
+++ libdom/bindings/xml/expat_xmlparser.c 2025-01-09 09:43:54.130555298 +0100
@@ -484,7 +484,7 @@
UNUSED(int_enc);
- parser = calloc(sizeof(*parser), 1);
+ parser = calloc(1, sizeof(*parser));
if (parser == NULL) {
msg(DOM_MSG_CRITICAL, mctx, "No memory for parser");
return NULL;
Index: libdom/src/core/node.c
===================================================================
--- libdom.orig/src/core/node.c 2025-01-09 09:03:48.891278374 +0100
+++ libdom/src/core/node.c 2025-01-09 09:47:12.527863638 +0100
@@ -2379,7 +2379,7 @@
if (t == NULL) {
/* Create the event target list */
size = 64;
- t = calloc(sizeof(*t), size);
+ t = calloc(size, sizeof(*t));
if (t == NULL) {
return DOM_NO_MEM_ERR;
}
Index: libdom/src/html/html_document.c
===================================================================
--- libdom.orig/src/html/html_document.c 2025-01-09 09:03:48.895278321 +0100
+++ libdom/src/html/html_document.c 2025-01-09 09:46:43.292259826 +0100
@@ -134,13 +134,13 @@
doc->cookie = NULL;
doc->body = NULL;
- doc->memoised = calloc(sizeof(dom_string *), hds_COUNT);
+ doc->memoised = calloc(hds_COUNT, sizeof(dom_string *));
if (doc->memoised == NULL) {
error = DOM_NO_MEM_ERR;
goto out;
}
- doc->elements = calloc(sizeof(dom_string *),
- DOM_HTML_ELEMENT_TYPE__COUNT);
+ doc->elements = calloc(DOM_HTML_ELEMENT_TYPE__COUNT,
+ sizeof(dom_string *));
if (doc->elements == NULL) {
error = DOM_NO_MEM_ERR;
goto out;