[Github-comments] [geany/geany] Don't pass NULL to memcpy (PR #2960)

Avinash Sonawane notifications at xxxxx
Thu Oct 28 02:35:53 UTC 2021


@rootkea commented on this pull request.



> @@ -694,7 +694,8 @@ static gboolean spawn_async_with_pipes(const gchar *working_directory, const gch
 			for (argc = 0; argv[argc]; argc++);
 
 		full_argv = g_renew(gchar *, cl_argv, cl_argc + argc + 1);
-		memcpy(full_argv + cl_argc, argv, argc * sizeof(gchar *));
+		if (argv)

"If an argument to a function has an invalid value (such as a value outside the domain of the function, or a pointer outside the address space of the program, or **a null pointer**, or a pointer to non-modifiable storage when the corresponding parameter is not const-qualified) or a type (after promotion) not expected by a function with variable number of arguments, the **behavior is undefined**." - 7.1.4

Also,

"Where an argument declared as `size_t n` specifies the length of the array for a function, n can have the value zero on a call to that function. Unless explicitly stated otherwise in the description of a particular function in this subclause, pointer arguments on such a call shall still have valid values, as described in 7.1.4." - 7.24.1

Source: https://web.archive.org/web/20181230041359if_/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/2960#discussion_r737976987
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211027/aa3deb7f/attachment.htm>


More information about the Github-comments mailing list