Skip to content

Possible memory leak when creating a region #8

@psychon

Description

@psychon

I just noticed a possible memory leak:

oocairo/obj_region.c

Lines 40 to 50 in 2aba6f9

static int
region_create_rectangles (lua_State *L) {
size_t max_entries = lua_objlen (L, 1);
cairo_rectangle_int_t *rects = calloc(max_entries, sizeof(*rects));
size_t i = 0;
/* Now iterate over the table */
lua_pushnil(L);
while (lua_next(L, 1) != 0) {
if (i >= max_entries)
return luaL_error(L, "Cairo.region_create_rectangles(): Internal error, table larger than table?!");

The calloc result is leaked if an error happens (either via luaL_error or via lua_next doing a longjmp).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions