diff --git a/dmserver/src/abstract_display.cpp b/dmserver/src/abstract_display.cpp index e304934e..0b85b332 100644 --- a/dmserver/src/abstract_display.cpp +++ b/dmserver/src/abstract_display.cpp @@ -33,7 +33,7 @@ AbstractDisplay::AbstractDisplay(const DisplayInfo* info) id_ = info->GetDisplayId(); width_ = info->GetWidth(); height_ = info->GetHeight(); - freshRate_ = info->GetHeight(); + freshRate_ = info->GetFreshRate(); } AbstractDisplay::AbstractDisplay(DisplayId id, ScreenId screenId, int32_t width, int32_t height, uint32_t freshRate) diff --git a/interfaces/kits/napi/display/js_display_manager.cpp b/interfaces/kits/napi/display/js_display_manager.cpp index d53330a4..a8afaad0 100644 --- a/interfaces/kits/napi/display/js_display_manager.cpp +++ b/interfaces/kits/napi/display/js_display_manager.cpp @@ -14,6 +14,7 @@ */ #include +#include #include "js_runtime_utils.h" #include "native_engine/native_reference.h" @@ -152,7 +153,11 @@ void RegisterDisplayListenerWithType(NativeEngine& engine, const std::string& ty } std::unique_ptr callbackRef; callbackRef.reset(engine.CreateReference(value, 1)); - sptr displayListener = new JsDisplayListener(&engine); + sptr displayListener = new(std::nothrow) JsDisplayListener(&engine); + if (displayListener == nullptr) { + WLOGFE("displayListener is nullptr"); + return; + } if (type == "add" || type == "remove" || type == "change") { SingletonContainer::Get().RegisterDisplayListener(displayListener); WLOGFI("JsDisplayManager::RegisterDisplayListenerWithType success"); diff --git a/interfaces/kits/napi/display_runtime/napi/js_screen_manager.cpp b/interfaces/kits/napi/display_runtime/napi/js_screen_manager.cpp index b601166e..8f74813a 100644 --- a/interfaces/kits/napi/display_runtime/napi/js_screen_manager.cpp +++ b/interfaces/kits/napi/display_runtime/napi/js_screen_manager.cpp @@ -12,10 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "js_screen_manager.h" #include - +#include #include #include "js_runtime_utils.h" #include "js_screen_listener.h" @@ -138,7 +139,11 @@ void RegisterScreenListenerWithType(NativeEngine& engine, const std::string& typ } std::unique_ptr callbackRef; callbackRef.reset(engine.CreateReference(value, 1)); - sptr screenListener = new JsScreenListener(&engine); + sptr screenListener = new(std::nothrow) JsScreenListener(&engine); + if (screenListener == nullptr) { + WLOGFE("screenListener is nullptr"); + return; + } if (type == "connect" || type == "disconnect" || type == "change") { SingletonContainer::Get().RegisterScreenListener(screenListener); WLOGFI("JsScreenManager::RegisterScreenListenerWithType success"); diff --git a/utils/src/surface_reader.cpp b/utils/src/surface_reader.cpp index af49492a..0ed3e689 100644 --- a/utils/src/surface_reader.cpp +++ b/utils/src/surface_reader.cpp @@ -117,9 +117,9 @@ bool SurfaceReader::ProcessBuffer(const sptr &buf) return false; } - uint32_t width = bufferHandle->width; - uint32_t height = bufferHandle->height; - uint32_t stride = bufferHandle->stride; + uint32_t width = static_cast(bufferHandle->width); + uint32_t height = static_cast(bufferHandle->height); + uint32_t stride = static_cast(bufferHandle->stride); uint8_t *addr = (uint8_t *)buf->GetVirAddr(); auto data = (uint8_t *)malloc(width * height * BPP); @@ -137,8 +137,8 @@ bool SurfaceReader::ProcessBuffer(const sptr &buf) sptr pixelMap = new PixelMap(); ImageInfo info; - info.size.width = width; - info.size.height = height; + info.size.width = static_cast(width); + info.size.height = static_cast(height); info.pixelFormat = PixelFormat::RGBA_8888; info.colorSpace = ColorSpace::SRGB; pixelMap->SetImageInfo(info);