Thread (10 messages) flat view 10 messages, 4 authors, 2016-06-15
STALE3715d

[PATCH 3/2] argv-array: fix bogus cast when freeing array

From: Jeff King <hidden>
Date: 2016-06-15 22:54:37
Subsystem: the rest · Maintainer: Linus Torvalds

On Sat, Sep 01, 2012 at 07:32:07AM -0400, Jeff King wrote:
Since the array struct stores a "const char **" argv member
(for compatibility with most of our argv-taking functions),
we have to cast away the const-ness when freeing its
elements.

However, we used the wrong type when doing so.  It doesn't
make a difference since free() take a void pointer anyway,
but it can be slightly confusing to a reader.

Signed-off-by: Jeff King <redacted>
---
Noticed this while I was adding the other free in argv_array_pop...
Argh, managed to botch the subject line. Here it is for real.

-- >8 --
Since the array struct stores a "const char **" argv member
(for compatibility with most of our argv-taking functions),
we have to cast away the const-ness when freeing its
elements.

However, we used the wrong type when doing so.  It doesn't
make a difference since free() take a void pointer anyway,
but it can be slightly confusing to a reader.

Signed-off-by: Jeff King <redacted>
---
 argv-array.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/argv-array.c b/argv-array.c
index 55e8443..256741d 100644
--- a/argv-array.c
+++ b/argv-array.c
@@ -63,7 +63,7 @@ void argv_array_clear(struct argv_array *array)
 	if (array->argv != empty_argv) {
 		int i;
 		for (i = 0; i < array->argc; i++)
-			free((char **)array->argv[i]);
+			free((char *)array->argv[i]);
 		free(array->argv);
 	}
 	argv_array_init(array);
-- 
1.7.12.rc3.8.g89db099
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help