Skip to content

Commit

Permalink
Fix some incorrect error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdrake committed Jun 1, 2015
1 parent 41a763c commit f0917f7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions extension/boolexpr/array2.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#include "boolexpr.h"


/* array.c */
struct BoolExprArray * _bx_array_from(size_t length, struct BoolExpr **items);

/* boolexpr.c */
struct BoolExpr * _op_new(BoolExprKind kind, size_t n, struct BoolExpr **xs);

Expand Down Expand Up @@ -86,15 +89,19 @@ _multiply(struct BoolExprArray *a, struct BoolExprArray *b, BoolExprKind kind)
for (size_t i = 0, index = 0; i < a->length; ++i) {
for (size_t j = 0; j < b->length; ++j, ++index) {
struct BoolExpr *xs[2] = {a->items[i], b->items[j]};
CHECK_NULL_N(items[index], _op_new(kind, 2, xs), index, items);
items[index] = _op_new(kind, 2, xs);
if (items[index] == NULL) {
for (size_t k = 0; k < j; ++k)
BoolExpr_DecRef(items[k]);
free(items);
}
}
}

CHECK_NULL_N(prod, BoolExprArray_New(length, items), length, items);
prod = _bx_array_from(length, items);

for (size_t i = 0; i < length; ++i)
BoolExpr_DecRef(items[i]);
free(items);

return prod;
}
Expand Down

0 comments on commit f0917f7

Please sign in to comment.