]> Chaos Git - corbenik/ctrulib.git/commitdiff
Fixed socket() error handling when cmdbuf[2] is actually an error-code, not a handle...
authoryellows8 <yellows8@users.noreply.github.com>
Thu, 2 Jul 2015 22:53:16 +0000 (18:53 -0400)
committeryellows8 <yellows8@users.noreply.github.com>
Thu, 2 Jul 2015 22:53:16 +0000 (18:53 -0400)
libctru/source/services/soc/soc_socket.c

index 5072275c013ace9e7b13b52667bb3aeceb1f27fd..bf0270017b36c99fc10f397cef397beff71995bd 100644 (file)
@@ -41,9 +41,11 @@ int socket(int domain, int type, int protocol)
        }
 
        ret = (int)cmdbuf[1];
-       if(ret != 0) {
+       if(ret == 0)ret = cmdbuf[2];
+       if(ret < 0) {
                __release_handle(fd);
-               errno = _net_convert_error(cmdbuf[2]);
+               if(cmdbuf[1] == 0)errno = _net_convert_error(ret);
+               if(cmdbuf[1] != 0)errno = SYNC_ERROR;
                return -1;
        }