Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src/tool_parsecfg.c:288 -- free(pathalloc) is not required in parseconfig() #4730

Closed
bxac opened this issue Dec 18, 2019 · 9 comments
Closed

Comments

@bxac
Copy link

bxac commented Dec 18, 2019

I did this

mkdir build_x64_shared
cd build_x64_shared
cmake -G "Visual Studio 16 2019" -A x64 .. -DCMAKE_USE_WINSSL=ON -DCURL_WINDOWS_SSPI=ON -DCURL_STATICLIB=OFF -DCURL_STATIC_CRT=ON -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF ..
cmake --build . --config Debug -- /m

I expected the following

Expecting working curl.exe, but it fires debug assertion in debug_heap.cpp:996 ( _ASSERTE(__acrt_first_block == header); )

curl/libcurl version

curl 7.68.0-DEV (Windows) libcurl/7.68.0-DEV Schannel
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS IPv6 Kerberos Largefile NTLM SPNEGO SSL SSPI

operating system

Microsoft Windows [Version 10.0.18362.535]

@dfandrich
Copy link
Contributor

dfandrich commented Dec 18, 2019 via email

@bagder
Copy link
Member

bagder commented Dec 18, 2019

(and the free() is obviously needed, as otherwise that function would leak that memory)

@bxac
Copy link
Author

bxac commented Dec 18, 2019

What command-line causes this?

Just "curl.exe" w/o parameters.

(and the free() is obviously needed, as otherwise that function would leak that memory)

Seems "pathalloc" isn't allocated from heap at this point.

@bagder
Copy link
Member

bagder commented Dec 18, 2019

Seems "pathalloc" isn't allocated from heap at this point.

If it isn't, then it is NULL, right? Because if you can get it to be non-NULL and not allocated then I'm curious how!

@bxac
Copy link
Author

bxac commented Dec 18, 2019

No, it is not NULL (checked in VS debugger).

Because if you can get it to be non-NULL and not allocated then I'm curious how!

I'm curious too. That's why I've created this issue instead of pull-request with fix.

@bagder
Copy link
Member

bagder commented Dec 18, 2019

If you run it in the debugger, how about setting a break-point on the first line of the function and just single-step until that free() and see where it gets assigned? It seems likely to be a call to curl_maprintf() ...

@bxac
Copy link
Author

bxac commented Dec 18, 2019

where it gets assigned? It seems likely to be a call to curl_maprintf() ...

Yes, in line
pathalloc = curl_maprintf("%s%s%ccurlrc", home, DIR_CHAR, prefix);

And if I add
free(pathalloc);
after that line, I got assert there.

But free(home) works without assert.

@bagder
Copy link
Member

bagder commented Dec 18, 2019

Ah, it should be a curl_free() !

bagder added a commit that referenced this issue Dec 18, 2019
@bagder
Copy link
Member

bagder commented Dec 18, 2019

Will work on the fix in #4731

@bagder bagder closed this as completed in 23e4d98 Dec 18, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

3 participants