fjpanag commented on code in PR #1713:
URL: https://github.com/apache/nuttx-apps/pull/1713#discussion_r1174417119


##########
netutils/ftpc/ftpc_transfer.c:
##########
@@ -247,7 +247,10 @@ static FAR char *ftpc_abspath(FAR struct ftpc_session_s 
*session,
 
       else if (relpath[1] == '/')
         {
-          asprintf(&ptr, "%s%s", homedir, &relpath[1]);
+          if (asprintf(&ptr, "%s%s", homedir, &relpath[1]) < 0)
+            {
+              ptr = NULL;

Review Comment:
   As said, the contents of the pointer are undefined if `asprintf` fails.
   
   So `asprintf` can set a value to this pointer, and *then* fail. In this case 
it is not required for it to restore it to NULL. Thus the pointer now contains 
garbage.
   
   If you need to be sure that the pointer is `NULL` after an `asprintf` 
failure, then it must be explicitly set so, *after* the `asprintf` call.



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

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

Reply via email to