diff --git a/dom/network/TCPSocketChild.cpp b/dom/network/TCPSocketChild.cpp index e93b448db26..2de5ecfbe84 100644 --- a/dom/network/TCPSocketChild.cpp +++ b/dom/network/TCPSocketChild.cpp @@ -34,7 +34,9 @@ DeserializeArrayBuffer(JSContext* cx, JSObject* obj = JS_NewArrayBufferWithContents(cx, aBuffer.Length(), data.get()); if (!obj) return false; - data.release(); + // If JS_NewArrayBufferWithContents returns non-null, the ownership of + // the data is transfered to obj, so we release the ownership here. + mozilla::Unused << data.release(); aVal.setObject(*obj); return true; diff --git a/dom/workers/FileReaderSync.cpp b/dom/workers/FileReaderSync.cpp index 5bd8e0122e4..4620544e483 100644 --- a/dom/workers/FileReaderSync.cpp +++ b/dom/workers/FileReaderSync.cpp @@ -7,6 +7,7 @@ #include "FileReaderSync.h" #include "jsfriendapi.h" +#include "mozilla/unused.h" #include "mozilla/Base64.h" #include "mozilla/dom/EncodingUtils.h" #include "mozilla/dom/File.h" @@ -85,7 +86,9 @@ FileReaderSync::ReadAsArrayBuffer(JSContext* aCx, aRv.Throw(NS_ERROR_OUT_OF_MEMORY); return; } - bufferData.release(); + // arrayBuffer takes the ownership when it is not null. Otherwise we + // need to release it explicitly. + mozilla::Unused << bufferData.release(); aRetval.set(arrayBuffer); } diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index 71b31b11c0e..59e702d3ba7 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -7,6 +7,7 @@ #include "builtin/TestingFunctions.h" #include "mozilla/Move.h" +#include "mozilla/unused.h" #include @@ -2612,7 +2613,7 @@ FindPath(JSContext* cx, unsigned argc, Value* vp) RootedString edgeStr(cx, NewString(cx, edgeName.get(), js_strlen(edgeName.get()))); if (!edgeStr) return false; - edgeName.release(); // edgeStr acquired ownership + mozilla::Unused << edgeName.release(); // edgeStr acquired ownership if (!JS_DefineProperty(cx, obj, "edge", edgeStr, JSPROP_ENUMERATE, nullptr, nullptr)) return false; diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index 2f27187670e..f100561851b 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -13,6 +13,7 @@ #include "mozilla/PodOperations.h" #include "mozilla/Range.h" #include "mozilla/TypeTraits.h" +#include "mozilla/unused.h" #include #include @@ -645,7 +646,7 @@ ToLowerCase(JSContext* cx, JSLinearString* str) if (!res) return nullptr; - newChars.release(); + mozilla::Unused << newChars.release(); return res; } @@ -788,13 +789,13 @@ ToUpperCase(JSContext* cx, JSLinearString* str) if (!res) return nullptr; - newChars.ref().release(); + mozilla::Unused << newChars.ref().release(); } else { res = NewStringDontDeflate(cx, newChars.ref().get(), length); if (!res) return nullptr; - newChars.ref().release(); + mozilla::Unused << newChars.ref().release(); } return res;