Re: [PATCH] path: use xmalloc in add_to_trie
- From
Stefan Beller <sbeller@google.com>
- Date
- Oct 24, 2017, 16:13 UTC
- Message-ID
- <CAGZ79kZM_hVi8BeTmL5u_QK5+=1g3gcPsccEe1AJVpDLUWz_9Q@mail.gmail.com>
- In-Reply-To
- <e63c2208-900e-138a-a13c-fecf9403e0b8@samsung.com>
On Tue, Oct 24, 2017 at 8:15 AM, Andrey Okoshkin <a.okoshkin@samsung.com> wrote:
Show 10 quoted lines
> Add usage of xmalloc() instead of malloc() in add_to_trie() as xmalloc wraps > and checks memory allocation result. > > Signed-off-by: Andrey Okoshkin <a.okoshkin@samsung.com> > --- > Hello, > I'm not sure but it looks like there is a missing check of the malloc result. > memcpy() may crash with SIGSEGV due to the memory allocation failure. > make_trie_node() uses xmalloc() and xcalloc() - so I believe add_to_trie() > also should use it.
Good catch! Thanks for spotting.
Trying to find similar occurrences via git grep "= malloc" did not yield other places that need the same fix.
Thanks, Stefan