Skip to content

Use curl_getenv in Curl_qlogdir#18170

Closed
dvdzhuang wants to merge 3 commits into
curl:masterfrom
dvdzhuang:vquic-getenv
Closed

Use curl_getenv in Curl_qlogdir#18170
dvdzhuang wants to merge 3 commits into
curl:masterfrom
dvdzhuang:vquic-getenv

Conversation

@dvdzhuang

Copy link
Copy Markdown
Contributor

getenv isn't defined on all platforms, which prevents vquic from building. I specifically ran into this issue building on PlayStation.

@github-actions github-actions Bot added the HTTP/3 h3 or quic related label Aug 4, 2025
@vszakats

vszakats commented Aug 5, 2025

Copy link
Copy Markdown
Member

Would you mind posting more details about your environment/toolchain
and the build output?

@dvdzhuang

Copy link
Copy Markdown
Contributor Author

Sure; this is a follow-up on this change: d31a842

Sony has its own version of clang and ld, and the PlayStation SDK derives from FreeBSD but with quirks. I'm building curl 8.14.1 with nghttp3 1.10.9, ngtcp2 1.12.90, and OpenSSL 3.5.0.

This is the output:

[1]  <source dir>/curl/lib/vquic/vquic.c:648:26: error: call to undeclared function 'getenv'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
[1]    648 |   const char *qlog_dir = getenv("QLOGDIR");
[1]        |                          ^
[1]  <source dir>/curl/lib/vquic/vquic.c:648:15: error: incompatible integer to pointer conversion initializing 'const char *' with an expression of type 'int' [-Wint-conversion]
[1]    648 |   const char *qlog_dir = getenv("QLOGDIR");
[1]        |               ^          ~~~~~~~~~~~~~~~~~
[1]  2 errors generated.

Comment thread lib/vquic/vquic.c Outdated
int *qlogfdp)
{
const char *qlog_dir = getenv("QLOGDIR");
const char *qlog_dir = curl_getenv("QLOGDIR");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curl_getenv() returns an allocated string, so with just replacement this seems to introduce a memory leak?

@dvdzhuang dvdzhuang Aug 5, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah sorry; I hadn't realized. Changed to make qlog_dir not const and freed at the end 👍

@bagder bagder closed this in 6058704 Aug 5, 2025
@bagder

bagder commented Aug 5, 2025

Copy link
Copy Markdown
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

HTTP/3 h3 or quic related

Development

Successfully merging this pull request may close these issues.

3 participants