Various fixes based on coverity errors #405
The main reason to make these macros is that it makes sure we set state->regs to NULL when we save registers so that any error path does not inadvertently free the caller's registers. Before we inconsistently set state->regs to NULL manually, and there were cases where we could have freed the caller's registers when encountering certain errors.
We were calling free on a pointer into the interior of an array
This allows us to remove some confused checking
These routines are now more resilient to being passed NULL arguments
The TREE argument must not be NULL, so there's no need to check for that later on
Fixing this to make coverity happy - it's unused code in a debugging routine
If we succeed in allocating INI ourselves, but then fail to push the initial state into it, we would leak INI. Fix that by explicitly freeing it.
When we tried to allocate BODY and allocation failed, we still had allocated memory in PARAMS that was not freed in the error label. We now free that list on error. To make sure we do not try and free PARAMS when it has been linked into FUNC, we set it to NULL after the call to BUILD_FUNC. The call to BUILD_FUNC also erroneously checked the return value for NULL, even though this function can never return NULL. This check was removed.
We used to call STRDUP for no good reason on the constant error message returned by PATHX_ERROR and promptly leaked it.
There was no good reason why we allocated a span here; in fact, it would only get leaked as there was nothing in visit_exit that would move the span into the tree.
…thx_exn make_pathx_exn already increases the reference count appropriately. The additional reference caused INFO to be leaked.
When parse failed, and we needed to skip the actual put, we used to return straight away, even though we were holding on to a number of intermediate data structures. Now we properly clean them up.
Otherwise, we might try to free cmd.opt before it has been set to NULL.
If we encountered an (internal) error in ENSURE, it was possible that we leaked SKEL and DICT. We now make sure they get set to NULL when we have saved them, and free them if they are not NULL yet.
When we went to clean up files that are not managed by a lens anymore, we just assumed that anything with a 'path' child held metadata for a file and removed that metadata and the actual contents. That could lead to a situation where creating a node /augeas/files/path would lead to a crash. We now use an explicit flag in the tree node that holds file metadata to indicate the fact rather than just inferring it from the presence of a 'path' child, so that we will never inadvertently free everything under /augeas/files.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments.