Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage/modules/vector_modn_sparse_c.pxi: allocate_c_vector_modint can leak memory in case of failure #4961

Closed
sagetrac-mabshoff mannequin opened this issue Jan 10, 2009 · 3 comments
Assignees
Milestone

Comments

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Jan 10, 2009

Look at

cdef int allocate_c_vector_modint(c_vector_modint* v, Py_ssize_t num_nonzero) except -1:
    """
    Allocate memory for a c_vector_modint -- most user code won't call this.
    """
    v.entries = <int*>sage_malloc(num_nonzero*sizeof(int))
    if v.entries == NULL:
        raise MemoryError, "Error allocating memory"
    v.positions = <Py_ssize_t*>sage_malloc(num_nonzero*sizeof(Py_ssize_t))
    if v.positions == NULL:
        raise MemoryError, "Error allocating memory"
    return 0

When the allocation for positions fails we will leak entries.

Cheers,

Michael

Component: memleak

Issue created by migration from https://trac.sagemath.org/ticket/4961

@sagetrac-mabshoff sagetrac-mabshoff mannequin added this to the sage-3.4 milestone Jan 10, 2009
@sagetrac-mabshoff sagetrac-mabshoff mannequin added t: bug labels Jan 10, 2009
@sagetrac-mabshoff sagetrac-mabshoff mannequin modified the milestones: sage-3.4, sage-3.3 Jan 12, 2009
@rlmill
Copy link
Mannequin

rlmill mannequin commented Jan 23, 2009

Attachment: trac-4961.patch.gz

@rlmill rlmill mannequin added the s: needs review label Jan 23, 2009
@sagetrac-mabshoff
Copy link
Mannequin Author

sagetrac-mabshoff mannequin commented Jan 23, 2009

comment:3

Positive review.

Cheers,

Michael

@sagetrac-mabshoff
Copy link
Mannequin Author

sagetrac-mabshoff mannequin commented Jan 24, 2009

comment:4

Merged in Sage 3.3.alpha2

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Jan 24, 2009
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant