Re: webkit-1.8.0-2: Patches for review
On Mon, 2012-04-16 at 23:00 +0200, Samuel Thibault wrote:
> Pino Toscano, le Mon 16 Apr 2012 22:51:01 +0200, a écrit :
> > ... but then you leak readLinkBuffer in both the cases (error return
> > value from readlink(), and success); you can do something like this:
> >
> > | CString resultString;
> > | if (result >= 0 && result < sb.st_size)
> > | resultString = CString(readLinkBuffer, result);
> > | free(readLinkBuffer);
> > | return resultString;
>
> Ah, CString returns a new object, not a trivial object pointing at the
Updated patch attached. OK now to add to bug #669059?
BTW: Doesn't the CString resultString; need to be initialized?
Or something like:
if (result >= 0 && result < sb.st_size)
resultString = CString(readLinkBuffer, result);
else
resultString = CString();
free(readLinkBuffer);
return resultString;
Of course the definition of resultString could be placed before first
statement, but it looks like in C++ people mix freely?
Still building; takes days to build this package...
--- a/Source/ThirdParty/ANGLE/src/compiler/osinclude.h 2012-02-19 18:47:57.000000000 +0100
+++ b/Source/ThirdParty/ANGLE/src/compiler/osinclude.h 2012-04-15 09:20:30.000000000 +0200
@@ -16,7 +16,7 @@
#define ANGLE_OS_WIN
#elif defined(__APPLE__) || defined(__linux__) || \
defined(__FreeBSD__) || defined(__OpenBSD__) || \
- defined(__sun) || defined(ANDROID)
+ defined(__sun) || defined(ANDROID) || defined(__GNU__)
#define ANGLE_OS_POSIX
#else
#error Unsupported platform.
--- a/Source/JavaScriptCore/wtf/gobject/GlibUtilities.cpp 2012-02-19 18:45:45.000000000 +0100
+++ b/Source/JavaScriptCore/wtf/gobject/GlibUtilities.cpp 2012-04-16 14:23:16.000000000 +0200
@@ -25,6 +25,8 @@
#include <wtf/text/WTFString.h>
#else
#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#endif
@@ -40,11 +42,19 @@
#elif OS(UNIX)
CString getCurrentExecutablePath()
{
- static char readLinkBuffer[PATH_MAX];
- ssize_t result = readlink("/proc/curproc/file", readLinkBuffer, PATH_MAX);
- if (result == -1)
- return CString();
- return CString(readLinkBuffer, result);
+ struct stat sb;
+ char *readLinkBuffer;
+ ssize_t result;
+ result = lstat("/proc/curproc/file", &sb);
+ readLinkBuffer = (char*)malloc(sb.st_size + 1);
+ if (readLinkBuffer == NULL)
+ return CString();
+ result = readlink("/proc/curproc/file", readLinkBuffer, sb.st_size + 1);
+ CString resultString;
+ if (result >= 0 && result < sb.st_size)
+ resultString = CString(readLinkBuffer, result);
+ free(readLinkBuffer);
+ return resultString;
}
#elif OS(WINDOWS)
CString getCurrentExecutablePath()
Reply to: