]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tool_formparse: avoid clobbering on function params
authorDaniel Gustafsson <daniel@yesql.se>
Thu, 8 Dec 2022 22:45:18 +0000 (23:45 +0100)
committerDaniel Gustafsson <daniel@yesql.se>
Thu, 8 Dec 2022 22:45:18 +0000 (23:45 +0100)
While perfectly legal to do, clobbering function parameters and using
them as local variables is confusing at best and rarely improves code
readability.  Fix by using a local variable instead, no functionality
is changed.

This also renames the parameter from data to mime_data since the term
data is (soft) reserved for the easy handle struct.

Closes: #10046
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
src/tool_formparse.c

index d4fc651e252c2cb9e8d09c9610ff4d1b42f78706..5dc24fe7ee0cd171fda6df7585feec4917c9fb8b 100644 (file)
@@ -61,17 +61,18 @@ static struct tool_mime *tool_mime_new_parts(struct tool_mime *parent)
 }
 
 static struct tool_mime *tool_mime_new_data(struct tool_mime *parent,
-                                            char *data)
+                                            char *mime_data)
 {
+  char *mime_data_copy;
   struct tool_mime *m = NULL;
 
-  data = strdup(data);
-  if(data) {
+  mime_data_copy = strdup(mime_data);
+  if(mime_data_copy) {
     m = tool_mime_new(parent, TOOLMIME_DATA);
     if(!m)
-      free(data);
+      free(mime_data_copy);
     else
-      m->data = data;
+      m->data = mime_data_copy;
   }
   return m;
 }