Hi ,
Please find corrected patch.
From 1a0269a1c24ac8ee07ac5d0133f2f816468e50d1 Mon Sep 17 00:00:00 2001 This patch adds check for realloc failure case and free arg_string before returning from splitstr() to avoid memory leaks Signed-off-by: Yogesh Gaur <yn.g...@samsung.com> diff --git a/pan/splitstr.c b/pan/splitstr.c
|
--
Regards
Manjeet
------- Original Message -------
Sender : Cyril Hrubis<chru...@suse.cz>
Date : Jun 01, 2015 23:22 (GMT+09:00)
Title : Re: [LTP] [PATCH]: Add check for realloc failure case
Hi!
> @@ -110,9 +111,13 @@ const char **splitstr(const char *str, const char *separator, int *argcount)
> cur_tok = strtok(NULL, separator);
> if (num_toks == max_toks) {
> max_toks += 20;
> - arg_array =
> - (char **)realloc((void *)arg_array,
> - sizeof(char *) * max_toks);
> + if((arg_array = realloc((void *)arg_array,sizeof(char *) * max_toks)) == NULL){
> + fprintf(stderr, "realloc: New memory allocation failed \n");
> + free(arg_array);
> + free(arg_string);
> + exit(1);
> + }
> +
These lines does not conform to LKML coding style.
There should be space before the opening curly brace '{', spaces after
coma, etc.
You can use checkpatch.pl shipped with linux kernel source to check your
patches before sending them.
--
Cyril Hrubis
chru...@suse.cz
|
------------------------------------------------------------------------------
_______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list