Skip to content

Commit e0516ec

Browse files
author
Simon Pinfold
committed
Fixed exception caused by native library overread
1 parent 80adbdb commit e0516ec

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/src/main/java/com/imgtec/hobbyist/flow/FlowEntities.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import android.content.Context;
1818
import android.os.Handler;
1919
import android.os.Message;
20+
import android.util.Log;
2021

2122
import com.imgtec.flow.Flow;
2223
import com.imgtec.flow.FlowHandler;
@@ -81,6 +82,7 @@ private void initUserAsyncHandler() {
8182
public void handleMessage(Message msg) {
8283
super.handleMessage(msg);
8384
String content = ((MessagingEvent) msg.obj).content;
85+
content = content.substring(0, content.lastIndexOf('>')+1);
8486
final AsyncMessage asyncMsg = AsyncMessage.newInstance(AsyncMessage.MessageType.RESPONSE, null);
8587
asyncMsg.setNodesFromXml(content);
8688
if (asyncMessageListener != null) {
@@ -92,6 +94,7 @@ public void handleMessage(Message msg) {
9294
asyncMessageListener.onCommandMessageReceived(asyncMsg);
9395
break;
9496
case ALERT:
97+
Log.e("initUserAsyncHandler", ""+alertListener);
9598
new Thread(new Runnable() {
9699
public void run() {
97100
if (alertListener != null) {
@@ -151,6 +154,7 @@ public void handleMessage(Message msg) {
151154
try {
152155
factory = XmlPullParserFactory.newInstance();
153156
xpp = factory.newPullParser();
157+
content = content.substring(0, content.lastIndexOf('>') + 1);
154158
xpp.setInput(new StringReader(content));
155159
int eventType = xpp.getEventType();
156160
while (eventType != XmlPullParser.END_DOCUMENT) {
@@ -200,6 +204,8 @@ public void handleMessage(Message msg) {
200204
}
201205
} catch (XmlPullParserException | IOException e) {
202206
DebugLogger.log(getClass().getSimpleName(), "parsing device presence xml failed");
207+
e.printStackTrace();
208+
Log.e(getClass().getSimpleName(), content);
203209
}
204210
}
205211
}
@@ -434,6 +440,8 @@ public void subscribeASyncMessaging() {
434440
flowInstance.subscribe(getUserFlowHandler(), getUserAor(),
435441
MessagingEvent.MessagingEventCategory.FLOW_MESSAGING_EVENTCATEGORY_ASYNC_MESSAGE_RESPONSE,
436442
"", 1200, asyncResponseHandler);
443+
444+
437445
}
438446

439447
/**

0 commit comments

Comments
 (0)