Fixed memory leaks.
authorErik Verbruggen <erik.verbruggen@me.com>
Tue, 15 Jan 2013 11:12:52 +0000 (12:12 +0100)
committerSimon Hausmann <simon.hausmann@digia.com>
Tue, 15 Jan 2013 15:27:29 +0000 (16:27 +0100)
Change-Id: I641127b0d46f88291468af767cbbeb28ce5a75d9
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
qmljs_engine.cpp
qmljs_environment.cpp
qmljs_environment.h
qv4ecmaobjects.cpp

index 30756e3..6367dcc 100644 (file)
@@ -216,6 +216,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
 ExecutionEngine::~ExecutionEngine()
 {
     delete globalObject.asObject();
+    rootContext->destroy();
     delete rootContext;
     qDeleteAll(functions);
     delete memoryManager;
index 067116d..15da373 100644 (file)
@@ -229,6 +229,12 @@ void ExecutionContext::init(ExecutionEngine *eng)
     eng->exception = Value::undefinedValue();
 }
 
+void ExecutionContext::destroy()
+{
+    delete[] arguments;
+    delete[] locals;
+}
+
 bool ExecutionContext::deleteProperty(String *name)
 {
     for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer()) {
index faa04aa..e4bb0b9 100644 (file)
@@ -96,8 +96,8 @@ struct ExecutionContext
         With *next;
     } *withObject;
 
-
     void init(ExecutionEngine *e);
+    void destroy();
 
     bool hasBinding(String *name) const;
     void createMutableBinding(String *name, bool deletable);
index fa1b398..5d743db 100644 (file)
@@ -298,10 +298,10 @@ static inline double DaylightSavingTA(double t)
 {
 #ifndef Q_WS_WIN
     long int tt = (long int)(t / msPerSecond);
-    struct tm *tmtm = localtime((const time_t*)&tt);
-    if (! tmtm)
+    struct tm tmtm;
+    if (!localtime_r((const time_t*)&tt, &tmtm))
         return 0;
-    return (tmtm->tm_isdst > 0) ? msPerHour : 0;
+    return (tmtm.tm_isdst > 0) ? msPerHour : 0;
 #else
     Q_UNUSED(t);
     /// ### implement me