mlang: Fix memory leaks in error paths (found by Smatch).
[wine] / dlls / vdhcp.vxd / vdhcp.c
1 /*
2  * VDHCP VxD implementation
3  *
4  * Copyright 2003 Juan Lang
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdarg.h>
22 #include "windef.h"
23 #include "winbase.h"
24 #include "wine/debug.h"
25
26 WINE_DEFAULT_DEBUG_CHANNEL(vxd);
27
28
29 /***********************************************************************
30  *           DeviceIoControl   (VDHCP.VXD.@)
31  */
32 BOOL WINAPI VDHCP_DeviceIoControl(DWORD dwIoControlCode, LPVOID lpvInBuffer,
33                                   DWORD cbInBuffer,
34                                   LPVOID lpvOutBuffer, DWORD cbOutBuffer,
35                                   LPDWORD lpcbBytesReturned,
36                                   LPOVERLAPPED lpOverlapped)
37 {
38     DWORD error;
39
40     switch (dwIoControlCode)
41     {
42     case 1:
43     {
44         /* since IpReleaseAddress/IpRenewAddress are not implemented, say there
45          * are no DHCP adapters
46          */
47         error = ERROR_FILE_NOT_FOUND;
48         break;
49     }
50
51     /* FIXME: don't know what this means */
52     case 5:
53         if (lpcbBytesReturned)
54             *lpcbBytesReturned = sizeof(DWORD);
55         if (lpvOutBuffer && cbOutBuffer >= sizeof(DWORD))
56         {
57             *(LPDWORD)lpvOutBuffer = 0;
58             error = NO_ERROR;
59         }
60         else
61             error = ERROR_BUFFER_OVERFLOW;
62         break;
63
64     default:
65         FIXME("(%d,%p,%d,%p,%d,%p,%p): stub\n",
66                 dwIoControlCode,
67                 lpvInBuffer,cbInBuffer,
68                 lpvOutBuffer,cbOutBuffer,
69                 lpcbBytesReturned,
70                 lpOverlapped);
71         error = ERROR_NOT_SUPPORTED;
72         break;
73     }
74     if (error)
75         SetLastError(error);
76     return error == NO_ERROR;
77 }