Protect the RegExp against early garbage collection
authorAlbert Astals Cid <albert.astals@canonical.com>
Tue, 14 Apr 2015 14:02:43 +0000 (16:02 +0200)
committerAlbert Astals Cid <albert.astals@canonical.com>
Tue, 14 Apr 2015 15:24:14 +0000 (15:24 +0000)
Backported from Qt 5.5

Change-Id: Ice9fd8061fac0c35d787e1603873c69f8ef7e10b
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/qml/jsruntime/qv4regexpobject.cpp

index c48175247eb45c029d3d04865a91d07de87875b5..e7f30c6671b3dd779cf68a815612743ae5b57d95 100644 (file)
@@ -286,7 +286,7 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData)
         }
     }
 
-    RegExp *regexp = reinterpret_cast<RegExp *>(RegExp::create(ctx->d()->engine, pattern, ignoreCase, multiLine));
+    Scoped<RegExp> regexp(scope, RegExp::create(ctx->d()->engine, pattern, ignoreCase, multiLine));
     if (!regexp->isValid())
         return ctx->throwSyntaxError(QStringLiteral("Invalid regular expression"));