On 06/03/2011 12:00 PM, Ivana Hutarova Varekova wrote:
> fix return value checks in load_list functions
>
> Signed-off-by: Ivana Hutarova Varekova <[email protected]>
> ---
>
> src/tools/cgsnapshot.c | 25 +++++++++++++++++++++----
> 1 files changed, 21 insertions(+), 4 deletions(-)
>
> diff --git a/src/tools/cgsnapshot.c b/src/tools/cgsnapshot.c
> index 0ff7435..8c8e268 100644
> --- a/src/tools/cgsnapshot.c
> +++ b/src/tools/cgsnapshot.c
> @@ -101,7 +101,7 @@ int load_list(char *filename, struct black_list_type
> **p_list)
> return 1;
> }
>
> - /* go through the all configuration file and search the line */
> + /* go through the configuration file and search the line */
> while (fgets(buf, FILENAME_MAX, fw) != NULL) {
> buf[FILENAME_MAX-1] = '\0';
> i = 0;
> @@ -118,13 +118,21 @@ int load_list(char *filename, struct black_list_type
> **p_list)
> if (new == NULL) {
> fprintf(stderr, "ERROR: Memory allocation problem "
> "(%s)\n", strerror(errno));
> - *p_list = NULL;
> - return 1;
> + ret = 1;
> + goto err;
> }
>
> ret = sscanf(buf, "%s", name);
> - new->name = strdup(name);
> + if (ret == 0)
> + continue;
>
> + new->name = strdup(name);
> + if (new->name == NULL) {
> + fprintf(stderr, "ERROR: Memory allocation problem "
> + "(%s)\n", strerror(errno));
> + ret = 1;
> + goto err;
> + }
> new->next = NULL;
>
> /* update the variables list */
> @@ -140,6 +148,15 @@ int load_list(char *filename, struct black_list_type
> **p_list)
> fclose(fw);
> *p_list = start;
> return 0;
> +
> +err:
> + new = start;
> + while (new != NULL) {
> + end = new->next;
> + free(new);
Looks like endless loop to me... It probably needs:
new = end; ?
> + }
> + *p_list = NULL;
> + return ret;
> }
>
> /* free list structure */
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Discover what all the cheering's about.
> Get your free trial download today.
> http://p.sf.net/sfu/quest-dev2dev2
> _______________________________________________
> Libcg-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/libcg-devel
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Discover what all the cheering's about.
Get your free trial download today.
http://p.sf.net/sfu/quest-dev2dev2
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel