Skip to content

Commit

Permalink
Bug 1693003 - Remove redundant nullptr checks of return value of infa…
Browse files Browse the repository at this point in the history
…llible new in dom/. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D105292
  • Loading branch information
sigiesec committed Feb 16, 2021
1 parent 9ab4b4f commit 06738f2
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 16 deletions.
3 changes: 0 additions & 3 deletions dom/canvas/CanvasRenderingContextHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,13 @@ CanvasRenderingContextHelper::CreateContextHelper(
Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_USED, 1);

ret = new ClientWebGLContext(/*webgl2:*/ false);
if (!ret) return nullptr;

break;

case CanvasContextType::WebGL2:
Telemetry::Accumulate(Telemetry::CANVAS_WEBGL_USED, 1);

ret = new ClientWebGLContext(/*webgl2:*/ true);
if (!ret) return nullptr;

break;

Expand All @@ -149,7 +147,6 @@ CanvasRenderingContextHelper::CreateContextHelper(
// Telemetry::Accumulate(Telemetry::CANVAS_WEBGPU_USED, 1);

ret = new webgpu::CanvasContext();
if (!ret) return nullptr;

break;

Expand Down
6 changes: 1 addition & 5 deletions dom/canvas/QueueParamTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -839,11 +839,7 @@ struct QueueParamTraits<UniquePtr<T>> {
return QueueStatus::kSuccess;
}

T* obj = nullptr;
obj = new T();
if (!obj) {
return QueueStatus::kOOMError;
}
T* obj = new T();
aArg->reset(obj);
return aConsumerView.ReadParam(obj);
}
Expand Down
2 changes: 0 additions & 2 deletions dom/events/EventListenerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,10 +1032,8 @@ nsresult EventListenerManager::CompileEventHandlerInternal(
RefPtr<ScriptFetchOptions> fetchOptions = new ScriptFetchOptions(
CORS_NONE, aElement->OwnerDoc()->GetReferrerPolicy(), aElement,
aElement->OwnerDoc()->NodePrincipal());
NS_ENSURE_TRUE(fetchOptions, NS_ERROR_OUT_OF_MEMORY);

RefPtr<EventScript> eventScript = new EventScript(fetchOptions, uri);
NS_ENSURE_TRUE(eventScript, NS_ERROR_OUT_OF_MEMORY);

JS::CompileOptions options(cx);
// Use line 0 to make the function body starts from line 1.
Expand Down
6 changes: 0 additions & 6 deletions dom/xslt/xslt/txXPathResultComparator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ nsresult txResultStringComparator::createSortableValue(Expr* aExpr,
txIEvalContext* aContext,
txObject*& aResult) {
UniquePtr<StringValue> val(new StringValue);
if (!val) {
return NS_ERROR_OUT_OF_MEMORY;
}

if (!mCollation) return NS_ERROR_FAILURE;

Expand Down Expand Up @@ -148,9 +145,6 @@ nsresult txResultNumberComparator::createSortableValue(Expr* aExpr,
txIEvalContext* aContext,
txObject*& aResult) {
UniquePtr<NumberValue> numval(new NumberValue);
if (!numval) {
return NS_ERROR_OUT_OF_MEMORY;
}

RefPtr<txAExprResult> exprRes;
nsresult rv = aExpr->evaluate(aContext, getter_AddRefs(exprRes));
Expand Down

0 comments on commit 06738f2

Please sign in to comment.