Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

* [Android] Avoid ArrayIndexOutOfBounds in RenderPage::MoveRenderObject #2919

Merged
merged 2 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public class WXBridgeManager implements Callback, BactchExecutor {
public static final String METHOD_UPDATE_COMPONENT_WITH_DATA = "UpdateComponentData";
private static final String METHOD_POST_TASK_TO_MSG_LOOP = "PostTaskToMsgLoop";
private static final String METHOD_JSFM_NOT_INIT_IN_EAGLE_MODE = "JsfmNotInitInEagleMode";
private static final String METHOD_MOVE_RENDER_OBJECT = "RenderPage::MoveRenderObject";
public static final String METHOD_DESTROY_INSTANCE = "destroyInstance";
public static final String METHOD_CALL_JS = "callJS";
public static final String METHOD_SET_TIMEOUT = "setTimeoutCallback";
Expand Down Expand Up @@ -2582,6 +2583,8 @@ public void reportJSException(String instanceId, String function,
METHOD_JSFM_NOT_INIT_IN_EAGLE_MODE.equals(function) )
&& !instance.getApmForInstance().hasAddView){
reportErrorCode = WXErrorCode.WX_DEGRAD_EAGLE_RENDER_ERROR;
} else if (METHOD_MOVE_RENDER_OBJECT.equals(function)) {
reportErrorCode = WXErrorCode.WX_ERROR_MOVE_RENDER_OBJECT_OUT_OF_BOUNDS;
}
instance.onJSException(reportErrorCode.getErrorCode(), function, exception);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ public enum WXErrorCode {

WX_ERR_HASH_MAP_TMP("-10010", "WX_ERR_HASH_MAP_TMP",ErrorType.NATIVE_ERROR,ErrorGroup.NATIVE),

WX_ERROR_MOVE_RENDER_OBJECT_OUT_OF_BOUNDS("-2120", "Index out of bounds when move element",
ErrorType.NATIVE_ERROR, ErrorGroup.JS),

/**
* TEST
*/
Expand Down
10 changes: 10 additions & 0 deletions weex_core/Source/core/render/page/render_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ bool RenderPage::MoveRenderObject(const std::string &ref,
}
}

if(index > new_parent->getChildCount()){
std::stringstream msg;
msg << "Out of array bounds when RenderPage::MoveRenderObject, specified index: "
<< index << "array size " << new_parent->getChildCount();

WeexCore::WeexCoreManager::Instance()->getPlatformBridge()->platform_side()
->ReportException(page_id().c_str(), "RenderPage::MoveRenderObject", msg.str().c_str());
return false;
}

set_is_dirty(true);
child->getParent()->removeChild(child);
new_parent->addChildAt(child, index);
Expand Down