]> Chaos Git - corbenik/ctrulib.git/commitdiff
In APT_CheckNew3DS_*, properly load+check the retval from the cmdbuf when svcSendSync...
authoryellows8 <yellows8@users.noreply.github.com>
Fri, 29 May 2015 21:15:55 +0000 (17:15 -0400)
committeryellows8 <yellows8@users.noreply.github.com>
Fri, 29 May 2015 21:15:55 +0000 (17:15 -0400)
libctru/source/services/apt.c

index 7fdad04e4e80a56c835d7cd33790a532773e954a..35771cd845ea7c8877e67cf1535f96e61d3b33ac 100644 (file)
@@ -1101,13 +1101,15 @@ Result APT_CheckNew3DS_Application(Handle* handle, u8 *out)
        Result ret=0;
        if((ret=svcSendSyncRequest(*handle)))return ret;
 
+       if(ret==0)ret = cmdbuf[1];
+
        if(out)
        {
                *out = 0;
                if(ret==0)*out=cmdbuf[2];
        }
 
-       return cmdbuf[1];
+       return ret;
 }
 
 Result APT_CheckNew3DS_System(Handle* handle, u8 *out)
@@ -1120,19 +1122,25 @@ Result APT_CheckNew3DS_System(Handle* handle, u8 *out)
        Result ret=0;
        if((ret=svcSendSyncRequest(*handle)))return ret;
 
+       if(ret==0)ret = cmdbuf[1];
+
        if(out)
        {
                *out = 0;
                if(ret==0)*out=cmdbuf[2];
        }
 
-       return cmdbuf[1];
+       return ret;
 }
 
 Result APT_CheckNew3DS(Handle* handle, u8 *out)
 {
        Result ret=0;
 
+       if(out==NULL)return -1;
+
+       *out = 0;
+
        if(__apt_new3dsflag_initialized)
        {
                *out = __apt_new3dsflag;