mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-04-23 08:47:02 +00:00
Fix crash on bad server response
This commit is contained in:
@@ -152,6 +152,11 @@ static const NSString* PORT = @"47984";
|
|||||||
|
|
||||||
NSString* string;
|
NSString* string;
|
||||||
xmlNodePtr rootNode = xmlDocGetRootElement(docPtr);
|
xmlNodePtr rootNode = xmlDocGetRootElement(docPtr);
|
||||||
|
if (rootNode == NULL) {
|
||||||
|
NSLog(@"ERROR: No root XML element.");
|
||||||
|
xmlFreeDoc(docPtr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
string = [HttpManager getStatusMessage: rootNode];
|
string = [HttpManager getStatusMessage: rootNode];
|
||||||
|
|
||||||
@@ -199,17 +204,27 @@ static const NSString* PORT = @"47984";
|
|||||||
|
|
||||||
+ (NSString*) getStatusMessage:(xmlNodePtr)docRoot {
|
+ (NSString*) getStatusMessage:(xmlNodePtr)docRoot {
|
||||||
xmlChar* statusMsgXml = xmlGetProp(docRoot, (const xmlChar*)"status_message");
|
xmlChar* statusMsgXml = xmlGetProp(docRoot, (const xmlChar*)"status_message");
|
||||||
NSString* statusMsg = [NSString stringWithUTF8String:(const char*)statusMsgXml];
|
NSString* statusMsg;
|
||||||
xmlFree(statusMsgXml);
|
if (statusMsgXml != NULL) {
|
||||||
|
statusMsg = [NSString stringWithUTF8String:(const char*)statusMsgXml];
|
||||||
|
xmlFree(statusMsgXml);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
statusMsg = @"Server Error";
|
||||||
|
}
|
||||||
|
|
||||||
return statusMsg;
|
return statusMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (bool) verifyStatus:(xmlNodePtr)docRoot {
|
+ (bool) verifyStatus:(xmlNodePtr)docRoot {
|
||||||
xmlChar* statusStr = xmlGetProp(docRoot, (const xmlChar*)"status_code");
|
xmlChar* statusStr = xmlGetProp(docRoot, (const xmlChar*)"status_code");
|
||||||
//NSLog(@"status: %s", statusStr);
|
if (statusStr != NULL) {
|
||||||
int status = [[NSString stringWithUTF8String:(const char*)statusStr] intValue];
|
int status = [[NSString stringWithUTF8String:(const char*)statusStr] intValue];
|
||||||
xmlFree(statusStr);
|
xmlFree(statusStr);
|
||||||
return status == 200;
|
return status == 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSData*) fixXmlVersion:(NSData*) xmlData {
|
+ (NSData*) fixXmlVersion:(NSData*) xmlData {
|
||||||
|
|||||||
Reference in New Issue
Block a user