[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
regex: avoid memory leak
From: |
Bruno Haible |
Subject: |
regex: avoid memory leak |
Date: |
Wed, 24 Jul 2019 05:03:08 +0200 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-154-generic; KDE/5.18.0; x86_64; ; ) |
Can someone please review this?
2019-07-23 Bruno Haible <address@hidden>
regex: Avoid memory leak.
Reported by Coverity (CID 1484201).
* lib/regex_internal.c (create_cd_newstate): Free newstate if we cannot
allocate newstate->entrance_nodes.
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index 9004ce8..02b2e09 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -1724,7 +1724,10 @@ create_cd_newstate (const re_dfa_t *dfa, const
re_node_set *nodes,
}
if (re_node_set_init_copy (newstate->entrance_nodes, nodes)
!= REG_NOERROR)
- return NULL;
+ {
+ free_state (newstate);
+ return NULL;
+ }
nctx_nodes = 0;
newstate->has_constraint = 1;
}
- regex: avoid memory leak,
Bruno Haible <=