You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "fjpanag (via GitHub)" <gi...@apache.org> on 2023/03/27 09:24:19 UTC
[GitHub] [nuttx] fjpanag opened a new pull request, #8911: asprintf: Fixed possible memory leak if print fails.
fjpanag opened a new pull request, #8911:
URL: https://github.com/apache/nuttx/pull/8911
## Summary
In `apsrintf`, when the memory allocation was successful, but the print to the buffer failed, the memory buffer will remain dangling.
This PR will handle this error case, free'ing the memory in case of such an issue, and eliminating the possible memory leak.
## Impact
Fixed possible memory leak.
## Testing
Build test.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] acassis merged pull request #8911: asprintf: Fixed possible memory leak if print fails.
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #8911:
URL: https://github.com/apache/nuttx/pull/8911
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] davids5 commented on a diff in pull request #8911: asprintf: Fixed possible memory leak if print fails.
Posted by "davids5 (via GitHub)" <gi...@apache.org>.
davids5 commented on code in PR #8911:
URL: https://github.com/apache/nuttx/pull/8911#discussion_r1150457885
##########
libs/libc/stdio/lib_vasprintf.c:
##########
@@ -119,14 +119,18 @@ int vasprintf(FAR char **ptr, FAR const IPTR char *fmt, va_list ap)
#endif
/* Return a pointer to the string to the caller. NOTE: the memstream put()
- * method has already added the NUL terminator to the end of the string
+ * method has already added the NULL terminator to the end of the string
Review Comment:
Oldtimers remember TTY really being a Teletype terminal. Here is where `NUL` is from.

--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] fjpanag commented on a diff in pull request #8911: asprintf: Fixed possible memory leak if print fails.
Posted by "fjpanag (via GitHub)" <gi...@apache.org>.
fjpanag commented on code in PR #8911:
URL: https://github.com/apache/nuttx/pull/8911#discussion_r1150376378
##########
libs/libc/stdio/lib_vasprintf.c:
##########
@@ -119,14 +119,18 @@ int vasprintf(FAR char **ptr, FAR const IPTR char *fmt, va_list ap)
#endif
/* Return a pointer to the string to the caller. NOTE: the memstream put()
- * method has already added the NUL terminator to the end of the string
+ * method has already added the NULL terminator to the end of the string
Review Comment:
First time I ever see it written like that... I thought it was a typo.
Anyway, fixed.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #8911: asprintf: Fixed possible memory leak if print fails.
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #8911:
URL: https://github.com/apache/nuttx/pull/8911#discussion_r1150456626
##########
libs/libc/stdio/lib_vasprintf.c:
##########
@@ -119,14 +119,18 @@ int vasprintf(FAR char **ptr, FAR const IPTR char *fmt, va_list ap)
#endif
/* Return a pointer to the string to the caller. NOTE: the memstream put()
- * method has already added the NUL terminator to the end of the string
+ * method has already added the NULL terminator to the end of the string
Review Comment:
Also some more info here https://www.ibm.com/docs/en/i/7.3?topic=essiccatus-nulls-nuls-in-c-c-applications-that-use-sql
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #8911: asprintf: Fixed possible memory leak if print fails.
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #8911:
URL: https://github.com/apache/nuttx/pull/8911#discussion_r1149403176
##########
libs/libc/stdio/lib_vasprintf.c:
##########
@@ -119,14 +119,18 @@ int vasprintf(FAR char **ptr, FAR const IPTR char *fmt, va_list ap)
#endif
/* Return a pointer to the string to the caller. NOTE: the memstream put()
- * method has already added the NUL terminator to the end of the string
+ * method has already added the NULL terminator to the end of the string
Review Comment:
```suggestion
* method has already added the NUL terminator to the end of the string
```
`NUL termination` term is used to state that there is `\0` char as a termination and not `NULL`
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] fjpanag commented on a diff in pull request #8911: asprintf: Fixed possible memory leak if print fails.
Posted by "fjpanag (via GitHub)" <gi...@apache.org>.
fjpanag commented on code in PR #8911:
URL: https://github.com/apache/nuttx/pull/8911#discussion_r1150464696
##########
libs/libc/stdio/lib_vasprintf.c:
##########
@@ -119,14 +119,18 @@ int vasprintf(FAR char **ptr, FAR const IPTR char *fmt, va_list ap)
#endif
/* Return a pointer to the string to the caller. NOTE: the memstream put()
- * method has already added the NUL terminator to the end of the string
+ * method has already added the NULL terminator to the end of the string
Review Comment:
Hmm indeed both seem "correct", although the NULL version is much more widely adopted. I have never seen it before as NUL (or maybe I also considered a typo?).
I propose to leave it as is for the moment. If we want to rectify this, then it can be a dedicated PR.
I see that there are 163 total occurrences in the code base. So, if it is to be changed, then it should be done for all of them at the same time, for consistency.
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on pull request #8911: asprintf: Fixed possible memory leak if print fails.
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on PR #8911:
URL: https://github.com/apache/nuttx/pull/8911#issuecomment-1487064090
Just rebase on top of the latest master
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] fjpanag commented on pull request #8911: asprintf: Fixed possible memory leak if print fails.
Posted by "fjpanag (via GitHub)" <gi...@apache.org>.
fjpanag commented on PR #8911:
URL: https://github.com/apache/nuttx/pull/8911#issuecomment-1487062529
The checks failure here is a CI issue, right?
--
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-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org