1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-26 05:52:06 +01:00

Add 'null' check to parseContentDepth

Does not fix the actual problem, but at least prevents resource
allocation until OOM.
This commit is contained in:
Florian Schmaus 2014-05-11 10:18:49 +02:00
parent e0b8577930
commit 98333e362d

View file

@ -156,7 +156,11 @@ public class PacketParserUtils {
public static String parseContentDepth(XmlPullParser parser, int depth) throws XmlPullParserException, IOException { public static String parseContentDepth(XmlPullParser parser, int depth) throws XmlPullParserException, IOException {
StringBuilder content = new StringBuilder(); StringBuilder content = new StringBuilder();
while (!(parser.next() == XmlPullParser.END_TAG && parser.getDepth() == depth)) { while (!(parser.next() == XmlPullParser.END_TAG && parser.getDepth() == depth)) {
content.append(parser.getText()); String text = parser.getText();
if (text == null) {
throw new IllegalStateException("Parser should never return 'null' on getText() here");
}
content.append(text);
} }
return content.toString(); return content.toString();
} }