From 0bbcfc4906d682b0b9aa29373fb7d79f29d0bae0 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Tue, 27 Dec 2022 18:16:27 +0900 Subject: [PATCH] Fix static analysis issues Change-Id: Ifbe7aec3bfa0f14c28e90ad69c0bbefef2ef884c Signed-off-by: Changgyu Choi --- src/stub.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/stub.cc b/src/stub.cc index 540ca4c..29e11e3 100644 --- a/src/stub.cc +++ b/src/stub.cc @@ -313,7 +313,13 @@ extern "C" EXPORT_API int bundle_encode(bundle *b, bundle_raw** raw, int* len) { return BUNDLE_ERROR_INVALID_PARAMETER; auto* h = reinterpret_cast(b); - *raw = reinterpret_cast(h->Encode()); + try { + *raw = reinterpret_cast(h->Encode()); + } catch (const Exception& e) { + *raw = nullptr; + return e.GetErrorCode(); + } + *len = strlen(reinterpret_cast(*raw)); return BUNDLE_ERROR_NONE; } -- 2.7.4