Reviewed by Darin.
* DumpRenderTree/LayoutTestController.cpp:
(pathToLocalResourceCallback): Dont leak the JSStringRef, and make
sure not to pass null to JSValueMakeString.
* DumpRenderTree/win/LayoutTestControllerWin.cpp:
(LayoutTestController::pathToLocalResource): Print an error message if
the conversion fails so it's clear what happened.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29406
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-01-11 Adam Roben <aroben@apple.com>
+
+ Fix a crash when pathToLocalResource fails and a leak
+
+ Reviewed by Darin.
+
+ * DumpRenderTree/LayoutTestController.cpp:
+ (pathToLocalResourceCallback): Dont leak the JSStringRef, and make
+ sure not to pass null to JSValueMakeString.
+ * DumpRenderTree/win/LayoutTestControllerWin.cpp:
+ (LayoutTestController::pathToLocalResource): Print an error message if
+ the conversion fails so it's clear what happened.
+
2008-01-11 Geoffrey Garen <ggaren@apple.com>
Reviewed by John Sullivan.
JSRetainPtr<JSStringRef> localPath(Adopt, JSValueToStringCopy(context, arguments[0], exception));
ASSERT(!*exception);
- return JSValueMakeString(context, controller->pathToLocalResource(context, localPath.get()));
+ JSRetainPtr<JSStringRef> convertedPath(Adopt, controller->pathToLocalResource(context, localPath.get()));
+ if (!convertedPath)
+ return JSValueMakeUndefined(context);
+
+ return JSValueMakeString(context, convertedPath.get());
}
static JSValueRef repaintSweepHorizontallyCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
JSStringRef LayoutTestController::pathToLocalResource(JSContextRef context, JSStringRef url)
{
+ wstring input(JSStringGetCharactersPtr(url), JSStringGetLength(url));
+
wstring localPath;
- if (!resolveCygwinPath(wstring(JSStringGetCharactersPtr(url), JSStringGetLength(url)), localPath))
+ if (!resolveCygwinPath(input, localPath)) {
+ printf("ERROR: Failed to resolve Cygwin path %S\n", input.c_str());
return 0;
+ }
return JSStringCreateWithCharacters(localPath.c_str(), localPath.length());
}