fix undefined behavior issue on Integrity
authorKonstantin Ritt <ritt.ks@gmail.com>
Tue, 17 Apr 2012 14:07:15 +0000 (17:07 +0300)
committerQt by Nokia <qt-info@nokia.com>
Thu, 19 Apr 2012 13:58:03 +0000 (15:58 +0200)
in contrast to ::strdup(), qstrdup() allocates memory via new[];
deallocating this memory with free() leads to undefine behavior.

Change-Id: I0692c4bef010c05de547283b00b6c6043ac24c79
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
mkspecs/unsupported/integrity-ghs/qplatformdefs.h
src/corelib/io/qprocess_unix.cpp

index 87459d8..4df7dea 100644 (file)
 #define QT_VSNPRINTF           ::vsnprintf
 #endif
 
+// INTEGRITY doesn't enable the declaration in _POSIX_SOURCE mode,
+// because strdup() is not part of strict Posix; declare it here
+extern "C" char *strdup(const char *src);
+
 #ifndef MAXNAMLEN
 #  define MAXNAMLEN NAME_MAX
 #endif
index fe13a9e..17dae7b 100644 (file)
@@ -117,13 +117,6 @@ QT_BEGIN_NAMESPACE
 // so we will use 512
 static const int errorBufferMax = 512;
 
-#ifdef Q_OS_INTEGRITY
-static inline char *strdup(const char *data)
-{
-    return qstrdup(data);
-}
-#endif
-
 static int qt_qprocess_deadChild_pipe[2];
 static struct sigaction qt_sa_old_sigchld_handler;
 static void qt_sa_sigchld_handler(int signum)