Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 3f2ea63 in mainline


Ignore:
Timestamp:
2012-08-01T20:44:10Z (9 years ago)
Author:
Sean Bartell <wingedtachikoma@…>
Branches:
lfn, master
Children:
23db8aa
Parents:
78d3a00
Message:

Bithenge: fix memory leak on error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bithenge/expression.c

    r78d3a00 r3f2ea63  
    285285        int rc;
    286286        const_expression_t *self = malloc(sizeof(*self));
    287         if (!self)
    288                 return ENOMEM;
     287        if (!self) {
     288                rc = ENOMEM;
     289                goto error;
     290        }
    289291
    290292        rc = bithenge_init_expression(const_as_expression(self),
    291293            &const_expression_ops);
    292         if (rc != EOK) {
    293                 free(self);
    294                 return rc;
    295         }
     294        if (rc != EOK)
     295                goto error;
    296296
    297297        self->node = node;
    298298        *out = const_as_expression(self);
    299299        return EOK;
     300
     301error:
     302        free(self);
     303        bithenge_node_dec_ref(node);
     304        return rc;
    300305}
    301306
Note: See TracChangeset for help on using the changeset viewer.