[Lldb-commits] [PATCH] Fix FileSpec::GetPath to return null-terminated strings

Zachary Turner zturner at google.com
Wed Feb 11 10:34:53 PST 2015


================
Comment at: source/API/SBModule.cpp:209-210
@@ -208,4 +208,4 @@
 
 const char *
 SBModule::GetUUIDString () const
 {
----------------
ki.stfu wrote:
> zturner wrote:
> > Note that this function is currently returning a pointer to stack memory, so it busted in more serious ways than you are currently addressing.  Because of that, I will suggest an alternative fix.
> No. It returns a pointer to static memory. 
Ahh you're right.  Although still not thread safe.

================
Comment at: source/Host/common/SocketAddress.cpp:35-36
@@ -34,4 +34,4 @@
 // TODO: implement shortened form "::" for runs of zeros
 const char* inet_ntop(int af, const void * src,
                       char * dst, socklen_t size)
 {
----------------
ki.stfu wrote:
> zturner wrote:
> > I would prefer if this function were changed to the following signature:
> > 
> > bool inet_ntop(int af, const void *src, llvm::SmallVector<char> &dst);
> It's a widely known POSIX function. We really want to change its prototype?
Sure, why not?  That's the whole point of the Host layer.  To provide a common interface to system calls which differ on different platforms.  Posix is just one platform that LLDB supports, and this function is an example of that.  As a result, generic code shouldn't be calling inet_ntop() anywhere, because that's a system call whose availability depends on the platform.  It should be calling a function from our host layer which calls inet_ntop() on posix, and does other stuff on platforms which don't have inet_ntop.

http://reviews.llvm.org/D7553

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the lldb-commits mailing list