diff mbox

[OpenWrt-Devel] list: remove double freeing of section

Message ID 1420529017-30472-1-git-send-email-yegorslists@googlemail.com
State Rejected
Headers show

Commit Message

Yegor Yefremov Jan. 6, 2015, 7:23 a.m. UTC
From: Yegor Yefremov <yegorslists@googlemail.com>

This error was reported by cppcheck. Compile tested only.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
 list.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

Comments

Felix Fietkau Jan. 6, 2015, 11:12 a.m. UTC | #1
On 2015-01-06 08:23, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> This error was reported by cppcheck. Compile tested only.
> 
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
>  list.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/list.c b/list.c
> index 0d00f81..46f8943 100644
> --- a/list.c
> +++ b/list.c
> @@ -346,7 +346,6 @@ uci_lookup_ext_section(struct uci_context *ctx, struct uci_ptr *ptr)
>  	goto done;
>  
>  error:
> -	free(section);
>  	memset(ptr, 0, sizeof(struct uci_ptr));
>  	UCI_THROW(ctx, UCI_ERR_INVAL);
False positive - the "done" part is never reached due to the UCI_THROW call.

- Felix
Yegor Yefremov Jan. 6, 2015, 11:20 a.m. UTC | #2
On Tue, Jan 6, 2015 at 12:12 PM, Felix Fietkau <nbd@openwrt.org> wrote:
> On 2015-01-06 08:23, yegorslists@googlemail.com wrote:
>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>
>> This error was reported by cppcheck. Compile tested only.
>>
>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>> ---
>>  list.c |    1 -
>>  1 files changed, 0 insertions(+), 1 deletions(-)
>>
>> diff --git a/list.c b/list.c
>> index 0d00f81..46f8943 100644
>> --- a/list.c
>> +++ b/list.c
>> @@ -346,7 +346,6 @@ uci_lookup_ext_section(struct uci_context *ctx, struct uci_ptr *ptr)
>>       goto done;
>>
>>  error:
>> -     free(section);
>>       memset(ptr, 0, sizeof(struct uci_ptr));
>>       UCI_THROW(ctx, UCI_ERR_INVAL);
> False positive - the "done" part is never reached due to the UCI_THROW call.

OK.

Compiler throws following warning for file.c because of deprecated mktemp usage

file.c:739: warning: the use of `mktemp' is dangerous, better use `mkstemp'

Is this worth fixing?

Yegor
diff mbox

Patch

diff --git a/list.c b/list.c
index 0d00f81..46f8943 100644
--- a/list.c
+++ b/list.c
@@ -346,7 +346,6 @@  uci_lookup_ext_section(struct uci_context *ctx, struct uci_ptr *ptr)
 	goto done;
 
 error:
-	free(section);
 	memset(ptr, 0, sizeof(struct uci_ptr));
 	UCI_THROW(ctx, UCI_ERR_INVAL);
 done: