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

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

bxac opened this issue Dec 18, 2019 · 9 comments

Comments

@bxac
Copy link

@bxac 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

This comment has been minimized.

Copy link
Collaborator

@dfandrich dfandrich commented Dec 18, 2019

@bagder

This comment has been minimized.

Copy link
Member

@bagder bagder commented Dec 18, 2019

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

@bxac

This comment has been minimized.

Copy link
Author

@bxac 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

This comment has been minimized.

Copy link
Member

@bagder 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

This comment has been minimized.

Copy link
Author

@bxac 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

This comment has been minimized.

Copy link
Member

@bagder 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

This comment has been minimized.

Copy link
Author

@bxac 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

This comment has been minimized.

Copy link
Member

@bagder bagder commented Dec 18, 2019

Ah, it should be a curl_free() !

bagder added a commit that referenced this issue Dec 18, 2019
Reported-by: bxac on github
Fixes #4730
@bagder

This comment has been minimized.

Copy link
Member

@bagder bagder commented Dec 18, 2019

Will work on the fix in #4731

@bagder bagder closed this in 23e4d98 Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.