You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by "PengZheng (via GitHub)" <gi...@apache.org> on 2023/03/01 06:20:30 UTC

[GitHub] [celix] PengZheng opened a new issue, #491: Check return value of `vasprintf` and `asprintf`

PengZheng opened a new issue, #491:
URL: https://github.com/apache/celix/issues/491

   According to `man asprintf`, leaving these return value unchecked is various dangerous: 
   
   > If memory allocation wasn't possible, or some other error occurs, these functions will return -1, and the contents of strp are undefined.
   
   ```C
   #define _GNU_SOURCE         /* See feature_test_macros(7)*/
   #include <stdio.h>
   
   int asprintf(char **strp, const char *fmt, ...);
   int vasprintf(char **strp, const char *fmt, va_list ap);
   
   ```
   It does fail for various reasons, e.g. EILSEQ ( A wide-character code that does not correspond to a valid character has been detected.)
   https://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html
   
   `asprintf` is used extensively in various modules, we need to check its usage carefully.


-- 
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: dev-unsubscribe@celix.apache.org.apache.org

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