You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/02/25 18:39:52 UTC

[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #2904: unistd/getcwd: enhance getcwd when buf is NULL

patacongo commented on a change in pull request #2904:
URL: https://github.com/apache/incubator-nuttx/pull/2904#discussion_r583075013



##########
File path: libs/libc/unistd/lib_getcwd.c
##########
@@ -115,6 +124,16 @@ FAR char *getcwd(FAR char *buf, size_t size)
       return NULL;
     }
 
+  if (buf == NULL)
+    {
+      buf = malloc(size);

Review comment:
       malloc() should not be used.  Use lib_malloc() instead.  That eliminates the problem case where this function is called from within the OS in certain build modes and malloc does not do what you would want it do do.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org