Skip to content

[BUG] math/prime_factoriziation.c type error #1568

@luyuduan

Description

@luyuduan

Description

AddressSanitizer: heap-buffer-overflow on: math/prime_factoriziation.c:132

int_fact() {
    int *range = (int *)malloc(sizeof(int) * len);
    assert(range);
    Range pstr = (Range)malloc(sizeof(range));  // sizeof(range) "type range" is same with  variable "int *range"
    assert(pstr);
}

Expected behavior

works normally, No error.

Actual behavior

ABORTING

Possible fix

Range pstr = (Range)malloc(sizeof(struct data));  //  This modification works normally 

or

Range pstr = (Range)malloc(sizeof(*pstr));  //  This modification works normally too

Steps to reproduce

None

Context

None

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions