Brad Bishop | e42b3e3 | 2020-01-15 22:08:42 -0500 | [diff] [blame] | 1 | From 67a8fa478a4484bc4dbfb3ac74e11be1dd5af594 Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Mon, 23 Dec 2019 19:35:48 -0800 |
| 4 | Subject: [PATCH] ensure the struct pointers are null initilized |
| 5 | |
| 6 | Do not delete if pointer is already null |
| 7 | |
| 8 | Upstream-Status: Pending |
| 9 | |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | --- |
| 12 | expr.c | 10 +++++----- |
| 13 | 1 file changed, 5 insertions(+), 5 deletions(-) |
| 14 | |
| 15 | diff --git a/expr.c b/expr.c |
| 16 | index 4059a32..5ffd0ad 100644 |
| 17 | --- a/expr.c |
| 18 | +++ b/expr.c |
| 19 | @@ -189,10 +189,8 @@ int |
| 20 | expr_clone(struct expr_node *retp, const struct expr_node *node) |
| 21 | { |
| 22 | *retp = *node; |
| 23 | - |
| 24 | + struct expr_node *nlhs = 0, *nrhs = 0; |
| 25 | switch (node->kind) { |
| 26 | - struct expr_node *nlhs; |
| 27 | - struct expr_node *nrhs; |
| 28 | |
| 29 | case EXPR_OP_ARGNO: |
| 30 | case EXPR_OP_SELF: |
| 31 | @@ -236,8 +234,10 @@ expr_clone(struct expr_node *retp, const struct expr_node *node) |
| 32 | if (expr_alloc_and_clone(&nlhs, node->lhs, node->own_lhs) < 0) { |
| 33 | if (node->kind == EXPR_OP_CALL2 |
| 34 | && node->u.call.own_rhs) { |
| 35 | - expr_destroy(nrhs); |
| 36 | - free(nrhs); |
| 37 | + if (nrhs) { |
| 38 | + expr_destroy(nrhs); |
| 39 | + free(nrhs); |
| 40 | + } |
| 41 | return -1; |
| 42 | } |
| 43 | } |
| 44 | -- |
| 45 | 2.24.1 |
| 46 | |