From aca39dd5d48b49658c72220fa114438c79741476 Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Wed, 29 Jan 2014 20:16:42 +0100 Subject: hdt: Fixing memory leak in cli The dynamically alloc'd string to protect from strtok modification has not been free'd on start_auto_mode() function. This patch insure the free is done properly. --- com32/hdt/hdt-cli.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c index 216b6bde..2895b13c 100644 --- a/com32/hdt/hdt-cli.c +++ b/com32/hdt/hdt-cli.c @@ -780,6 +780,8 @@ void start_auto_mode(struct s_hardware *hardware) mypch = strtok(NULL, AUTO_SEPARATOR); } + free(temp); + /* Executing found commands */ for (int i = 1; i <= nb_commands; i++) { if (commands[i]) { -- cgit v1.2.3 From 18d79b401ce15b29a5ee70cce928d231b1de032a Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Wed, 29 Jan 2014 20:28:08 +0100 Subject: acpi: Removing memset of buffer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no need to memset the buffer since the strncat will end the string with a \0. The memset was also almost wrong as doing a sizeof() on a char * could return 1 if buff was malloc'ed. We had chance as all the current calls are done with static buffers. Removing this memset call will make things clearer but also will prevent compilation warnings like : com32/gpllib/acpi/acpi.c:38:29: warning: argument to ‘sizeof’ in ‘memset’ call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess] memset(buffer, 0, sizeof(buffer)); --- com32/gpllib/acpi/acpi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/com32/gpllib/acpi/acpi.c b/com32/gpllib/acpi/acpi.c index d2bf29e5..3013f196 100644 --- a/com32/gpllib/acpi/acpi.c +++ b/com32/gpllib/acpi/acpi.c @@ -35,7 +35,6 @@ /* M1PS flags have to be interpreted as strings */ char *flags_to_string(char *buffer, uint16_t flags) { - memset(buffer, 0, sizeof(buffer)); strcpy(buffer, "default"); if ((flags & POLARITY_ACTIVE_HIGH) == POLARITY_ACTIVE_HIGH) strcpy(buffer, "high"); -- cgit v1.2.3