2025-01-30 07:04 UTC

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002885LibCSSLibCSSpublic2025-01-14 13:36
Reporterأحمد المحمودي 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen 
PlatformPOSIXOSLinuxOS Version
Summary0002885: Fails to build when compiled with -Werror=calloc-transposed-args
DescriptionWhen build libcss with -Werror=calloc-transposed-args, I get the following error:

src/select/computed.c: In function 'css__computed_style_create':
src/select/computed.c:76:27: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
   76 | s = calloc(sizeof(css_computed_style), 1);
      | ^~~~~~~~~~~~~~~~~~
src/select/computed.c:76:27: note: earlier argument should specify number of elements, later size of each element

The attached patch fixes the issue
TagsNo tags attached.
Fixed in CI build #
Reported in CI build #
Attached Files
  • patch file icon fix-calloc-args.patch (1,427 bytes) 2025-01-09 06:07 -
    Description: fix transposed calloc args
    Author: أحمد المحمودي (Ahmed El-Mahmoudy) <aelmahmoudy@users.sourceforge.net>
    
    Index: libcss/src/select/select.c
    ===================================================================
    --- libcss.orig/src/select/select.c	2025-01-09 06:53:13.082587500 +0100
    +++ libcss/src/select/select.c	2025-01-09 06:53:13.078587553 +0100
    @@ -138,7 +138,7 @@
     {
     	struct css_node_data *nd;
     
    -	nd = calloc(sizeof(struct css_node_data), 1);
    +	nd = calloc(1, sizeof(struct css_node_data));
     	if (nd == NULL) {
     		return CSS_NOMEM;
     	}
    @@ -234,7 +234,7 @@
     	if (result == NULL)
     		return CSS_BADPARM;
     
    -	c = calloc(sizeof(css_select_ctx), 1);
    +	c = calloc(1, sizeof(css_select_ctx));
     	if (c == NULL)
     		return CSS_NOMEM;
     
    @@ -613,7 +613,7 @@
     	*node_bloom = NULL;
     
     	/* Create the node's bloom */
    -	bloom = calloc(sizeof(css_bloom), CSS_BLOOM_SIZE);
    +	bloom = calloc(CSS_BLOOM_SIZE, sizeof(css_bloom));
     	if (bloom == NULL) {
     		return CSS_NOMEM;
     	}
    Index: libcss/src/select/computed.c
    ===================================================================
    --- libcss.orig/src/select/computed.c	2025-01-09 06:53:13.082587500 +0100
    +++ libcss/src/select/computed.c	2025-01-09 06:53:32.182337387 +0100
    @@ -73,7 +73,7 @@
     	if (result == NULL)
     		return CSS_BADPARM;
     
    -	s = calloc(sizeof(css_computed_style), 1);
    +	s = calloc(1, sizeof(css_computed_style));
     	if (s == NULL)
     		return CSS_NOMEM;
     
    
    patch file icon fix-calloc-args.patch (1,427 bytes) 2025-01-09 06:07 +

-Relationships
+Relationships

+Notes

-Issue History
Date Modified Username Field Change
2025-01-09 06:07 أحمد المحمودي New Issue
2025-01-09 06:07 أحمد المحمودي File Added: fix-calloc-args.patch
2025-01-14 13:36 Michael Orlitzky Note Added: 0002469
+Issue History