Fixed various memory leaks, allocation size issues and API misuse

warnings shown by clang as well as some compiler warnings.
This commit is contained in:
Armin Novak 2013-08-30 14:19:50 +02:00
parent 2a7ab454ba
commit e5c138a5b9
27 changed files with 180 additions and 66 deletions

View File

@ -146,8 +146,10 @@ void rdpsnd_select_supported_audio_formats(rdpsndPlugin* rdpsnd)
rdpsnd->NumberOfClientFormats = 0;
rdpsnd->ClientFormats = NULL;
rdpsnd->ClientFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * rdpsnd->NumberOfServerFormats);
if (!rdpsnd->NumberOfServerFormats)
return;
rdpsnd->ClientFormats = (AUDIO_FORMAT*) malloc(sizeof(AUDIO_FORMAT) * rdpsnd->NumberOfServerFormats);
for (index = 0; index < (int) rdpsnd->NumberOfServerFormats; index++)
{
serverFormat = &rdpsnd->ServerFormats[index];

View File

@ -1234,7 +1234,10 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
ZeroMemory(readerStates, readerCount * sizeof(SCARD_READERSTATE));
if (!readerStates)
{
free(pAtrMasks);
return smartcard_output_return(irp, SCARD_E_NO_MEMORY);
}
for (i = 0; i < readerCount; i++)
{
@ -1284,6 +1287,8 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
DEBUG_SCARD("Failure: %s (0x%08x)",
pcsc_stringify_error(status), (unsigned) status);
free(readerStates);
free(pAtrMasks);
return smartcard_output_return(irp, status);
}
@ -1313,7 +1318,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
Stream_Write_UINT32(irp->output, 0x00084dd8);
Stream_Write_UINT32(irp->output, readerCount);
for (i = 0, rsCur = readerStates; i < readerCount; i++, rsCur++)
for (i = 0, cur = readerStates; i < readerCount; i++, cur++)
{
Stream_Write_UINT32(irp->output, cur->dwCurrentState);
Stream_Write_UINT32(irp->output, cur->dwEventState);
@ -1328,6 +1333,7 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
smartcard_output_alignment(irp, 8);
free(readerStates);
free(pAtrMasks);
return status;
}

View File

@ -18,6 +18,7 @@
* limitations under the License.
*/
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -287,6 +288,9 @@ static int urdbrc_send_virtual_channel_add(IWTSVirtualChannel* channel, UINT32 M
LLOGLN(10, ("urdbrc_send_virtual_channel_add"));
assert(NULL != channel);
assert(NULL != channel->Write);
InterfaceId = ((STREAM_ID_PROXY<<30) | CLIENT_DEVICE_SINK);
out_size = 12;
@ -830,7 +834,10 @@ static int urbdrc_on_data_received(IWTSVirtualChannelCallback* pChannelCallback,
transfer_data = (TRANSFER_DATA*) malloc(sizeof(TRANSFER_DATA));
if (transfer_data == NULL)
{
fprintf(stderr, "transfer_data is NULL!!");
return 0;
}
transfer_data->callback = callback;
transfer_data->urbdrc = urbdrc;

View File

@ -206,9 +206,6 @@ int tfreerdp_run(freerdp* instance)
fd_set wfds_set;
rdpChannels* channels;
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
channels = instance->context->channels;
freerdp_connect(instance);
@ -218,6 +215,8 @@ int tfreerdp_run(freerdp* instance)
rcount = 0;
wcount = 0;
ZeroMemory(rfds, sizeof(rfds));
ZeroMemory(wfds, sizeof(wfds));
if (freerdp_get_fds(instance, rfds, &rcount, wfds, &wcount) != TRUE)
{
printf("Failed to get FreeRDP file descriptor\n");

View File

@ -11,7 +11,7 @@
LPSTR tmp = NULL;
LPCSTR tr_esc_str(LPCSTR arg)
LPSTR tr_esc_str(LPSTR arg)
{
size_t cs = 0, x, ds;
size_t s;
@ -26,7 +26,8 @@ LPCSTR tr_esc_str(LPCSTR arg)
s--;
/* Prepare a initial buffer with the size of the result string. */
tmp = malloc(s * sizeof(LPCSTR));
if (s)
tmp = (LPSTR)malloc(s * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not allocate string buffer.");
@ -41,7 +42,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
{
case '<':
ds += 3;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -54,7 +55,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '>':
ds += 3;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -67,7 +68,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '\'':
ds += 5;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -82,7 +83,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '"':
ds += 5;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");
@ -97,7 +98,7 @@ LPCSTR tr_esc_str(LPCSTR arg)
break;
case '&':
ds += 4;
tmp = realloc(tmp, ds * sizeof(LPCSTR));
tmp = (LPSTR)realloc(tmp, ds * sizeof(CHAR));
if( NULL == tmp )
{
fprintf(stderr, "Could not reallocate string buffer.");

View File

@ -1650,7 +1650,7 @@ void xf_ParamChangeEventHandler(rdpContext* context, ParamChangeEventArgs* e)
}
}
void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChangeEventArgs* e)
static void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChangeEventArgs* e)
{
xfContext* xfc = (xfContext*) context;
@ -1668,12 +1668,12 @@ void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChange
xf_transform_window(xfc);
{
ResizeWindowEventArgs e;
ResizeWindowEventArgs ev;
EventArgsInit(&e, "xfreerdp");
e.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor;
e.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor;
PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &e);
EventArgsInit(&ev, "xfreerdp");
ev.width = (int) xfc->originalWidth * xfc->settings->ScalingFactor;
ev.height = (int) xfc->originalHeight * xfc->settings->ScalingFactor;
PubSub_OnResizeWindow(((rdpContext*) xfc)->pubSub, xfc, &ev);
}
xf_draw_screen_scaled(xfc, 0, 0, 0, 0, FALSE);
@ -1683,19 +1683,19 @@ void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChange
* Client Interface
*/
void xfreerdp_client_global_init()
static void xfreerdp_client_global_init()
{
setlocale(LC_ALL, "");
freerdp_handle_signals();
freerdp_channels_global_init();
}
void xfreerdp_client_global_uninit()
static void xfreerdp_client_global_uninit()
{
freerdp_channels_global_uninit();
}
int xfreerdp_client_start(rdpContext* context)
static int xfreerdp_client_start(rdpContext* context)
{
xfContext* xfc = (xfContext*) context;
@ -1712,7 +1712,7 @@ int xfreerdp_client_start(rdpContext* context)
return 0;
}
int xfreerdp_client_stop(rdpContext* context)
static int xfreerdp_client_stop(rdpContext* context)
{
xfContext* xfc = (xfContext*) context;
@ -1735,7 +1735,7 @@ int xfreerdp_client_stop(rdpContext* context)
return 0;
}
int xfreerdp_client_new(freerdp* instance, rdpContext* context)
static int xfreerdp_client_new(freerdp* instance, rdpContext* context)
{
xfContext* xfc;
rdpSettings* settings;
@ -1791,7 +1791,7 @@ int xfreerdp_client_new(freerdp* instance, rdpContext* context)
return 0;
}
void xfreerdp_client_free(freerdp* instance, rdpContext* context)
static void xfreerdp_client_free(freerdp* instance, rdpContext* context)
{
xfContext* xfc = (xfContext*) context;

View File

@ -22,6 +22,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -179,8 +180,8 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
BYTE* src_ptr; /* used while copying compressed data */
BYTE* cptr; /* points to next byte in cbuf */
BYTE cur_byte; /* last byte fetched from cbuf */
int bits_left; /* bits left in d34 for processing */
int cur_bits_left; /* bits left in cur_byte for processing */
unsigned int bits_left; /* bits left in d34 for processing */
unsigned int cur_bits_left; /* bits left in cur_byte for processing */
int tmp;
UINT32 i32;
@ -330,6 +331,7 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
tmp = 32 - bits_left;
while (tmp)
@ -338,7 +340,7 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -527,6 +529,8 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -535,7 +539,7 @@ int decompress_rdp_4(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -769,6 +773,8 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -777,7 +783,7 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -990,6 +996,8 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -998,7 +1006,7 @@ int decompress_rdp_5(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)
@ -1322,6 +1330,8 @@ int decompress_rdp_6(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
*/
/* how may bits do we need to get? */
assert(bits_left <= 32);
assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
@ -1330,7 +1340,7 @@ int decompress_rdp_6(struct rdp_mppc_dec* dec, BYTE* cbuf, int len, int ctype, U
{
/* we have less bits than we need */
i32 = cur_byte >> (8 - cur_bits_left);
d32 |= i32 << ((32 - bits_left) - cur_bits_left);
d32 |= (i32 << ((32 - bits_left) - cur_bits_left)) & 0xFFFFFFFF;
bits_left += cur_bits_left;
tmp -= cur_bits_left;
if (cptr < cbuf + len)

View File

@ -21,6 +21,7 @@
#include "config.h"
#endif
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -756,6 +757,8 @@ static BOOL rfx_process_message_tileset(RFX_CONTEXT* context, RFX_MESSAGE* messa
if (context->priv->UseThreads)
{
assert(params);
params[i].context = context;
params[i].tile = message->tiles[i];
@ -1116,14 +1119,18 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
numTilesY = (height + 63) / 64;
message->numTiles = numTilesX * numTilesY;
message->tiles = (RFX_TILE**) malloc(sizeof(RFX_TILE) * message->numTiles);
ZeroMemory(message->tiles, sizeof(RFX_TILE) * message->numTiles);
if (message->numTiles)
{
message->tiles = (RFX_TILE**) malloc(sizeof(RFX_TILE*) * message->numTiles);
ZeroMemory(message->tiles, sizeof(RFX_TILE*) * message->numTiles);
}
DEBUG_RFX("x: %d y: %d width: %d height: %d scanline: %d BytesPerPixel: %d",
rect->x, rect->y, width, height, scanline, BytesPerPixel);
if (context->priv->UseThreads)
{
if (message->numTiles)
work_objects = (PTP_WORK*) malloc(sizeof(PTP_WORK) * message->numTiles);
if (!work_objects)
{
@ -1181,6 +1188,8 @@ RFX_MESSAGE* rfx_encode_message(RFX_CONTEXT* context, const RFX_RECT* rects,
if (context->priv->UseThreads)
{
assert(params);
params[i].context = context;
params[i].tile = tile;

View File

@ -503,7 +503,11 @@ HttpResponse* http_response_recv(rdpTls* tls)
}
http_response->count = count;
if (count)
{
http_response->lines = (char**) malloc(sizeof(char*) * http_response->count);
ZeroMemory(http_response->lines, sizeof(char*) * http_response->count);
}
count = 0;
line = strtok((char*) buffer, "\r\n");

View File

@ -295,6 +295,9 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT\n",
versionCaps->tsgHeader.ComponentId);
free(packetCapsResponse);
free(versionCaps);
free(packet);
return FALSE;
}
@ -324,6 +327,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
free(tsgCaps);
free(versionCaps);
free(packetCapsResponse);
free(packet);
return FALSE;
}
@ -399,6 +403,8 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu)
{
fprintf(stderr, "Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT\n",
versionCaps->tsgHeader.ComponentId);
free(versionCaps);
free(packetQuarEncResponse);
free(packet);
return FALSE;
}

View File

@ -64,9 +64,17 @@ BOOL update_read_icon_info(wStream* s, ICON_INFO* icon_info)
/* colorTable */
if (icon_info->colorTable == NULL)
{
if (icon_info->cbColorTable)
icon_info->colorTable = (BYTE*) malloc(icon_info->cbColorTable);
else
}
else if (icon_info->cbColorTable)
icon_info->colorTable = (BYTE*) realloc(icon_info->colorTable, icon_info->cbColorTable);
else
{
free(icon_info->colorTable);
icon_info->colorTable = NULL;
}
Stream_Read(s, icon_info->colorTable, icon_info->cbColorTable);
/* bitsColor */

View File

@ -395,8 +395,8 @@ char* crypto_cert_subject_common_name(X509* xcert, int* length)
char** crypto_cert_subject_alt_name(X509* xcert, int* count, int** lengths)
{
int index;
int length;
char** strings;
int length = 0;
char** strings = NULL;
BYTE* string;
int num_subject_alt_names;
GENERAL_NAMES* subject_alt_names;
@ -409,8 +409,11 @@ char** crypto_cert_subject_alt_name(X509* xcert, int* count, int** lengths)
return NULL;
num_subject_alt_names = sk_GENERAL_NAME_num(subject_alt_names);
if (num_subject_alt_names)
{
strings = (char**) malloc(sizeof(char*) * num_subject_alt_names);
*lengths = (int*) malloc(sizeof(int*) * num_subject_alt_names);
*lengths = (int*) malloc(sizeof(int) * num_subject_alt_names);
}
for (index = 0; index < num_subject_alt_names; ++index)
{

View File

@ -21,6 +21,8 @@
#include "config.h"
#endif
#include <assert.h>
#include <winpr/crt.h>
#include <winpr/sspi.h>
@ -717,6 +719,9 @@ void tls_print_certificate_name_mismatch_error(char* hostname, char* common_name
{
int index;
assert(NULL != hostname);
assert(NULL != common_name);
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@ WARNING: CERTIFICATE NAME MISMATCH! @\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
@ -726,11 +731,13 @@ void tls_print_certificate_name_mismatch_error(char* hostname, char* common_name
fprintf(stderr, "\t%s\n", common_name ? common_name : "no CN found in certificate");
if (alt_names_count > 1)
{
assert(NULL != alt_names);
fprintf(stderr, "Alternative names:\n");
if (alt_names_count > 1)
{
for (index = 0; index < alt_names_count; index++)
{
assert(alt_names[index]);
fprintf(stderr, "\t %s\n", alt_names[index]);
}
}

View File

@ -93,8 +93,11 @@ rdpIconCache* icon_cache_new(rdpRail* rail)
for (i = 0; i < cache->numCaches; i++)
{
cache->caches[i].entries = malloc(cache->numCacheEntries * sizeof(rdpIconCache));
ZeroMemory(cache->caches[i].entries, cache->numCacheEntries * sizeof(rdpIconCache));
if (cache->numCacheEntries)
{
cache->caches[i].entries = malloc(cache->numCacheEntries * sizeof(rdpIcon));
ZeroMemory(cache->caches[i].entries, cache->numCacheEntries * sizeof(rdpIcon));
}
}
}

View File

@ -658,8 +658,6 @@ static void* test_peer_mainloop(void* arg)
testPeerContext* context;
freerdp_peer* client = (freerdp_peer*) arg;
memset(rfds, 0, sizeof(rfds));
test_peer_init(client);
/* Initialize the real server settings here */
@ -694,6 +692,7 @@ static void* test_peer_mainloop(void* arg)
{
rcount = 0;
memset(rfds, 0, sizeof(rfds));
if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE)
{
printf("Failed to get FreeRDP file descriptor\n");
@ -779,12 +778,11 @@ static void test_server_mainloop(freerdp_listener* instance)
void* rfds[32];
fd_set rfds_set;
memset(rfds, 0, sizeof(rfds));
while (1)
{
rcount = 0;
memset(rfds, 0, sizeof(rfds));
if (instance->GetFileDescriptor(instance, rfds, &rcount) != TRUE)
{
printf("Failed to get FreeRDP file descriptor\n");

View File

@ -42,8 +42,6 @@ void* xf_server_thread(void* param)
xfServer* server;
freerdp_listener* listener;
ZeroMemory(rfds, sizeof(rfds));
server = (xfServer*) param;
listener = server->listener;
@ -51,6 +49,7 @@ void* xf_server_thread(void* param)
{
rcount = 0;
ZeroMemory(rfds, sizeof(rfds));
if (listener->GetFileDescriptor(listener, rfds, &rcount) != TRUE)
{
fprintf(stderr, "Failed to get FreeRDP file descriptor\n");

View File

@ -475,9 +475,9 @@ typedef struct _wEventType wEventType;
#define DEFINE_EVENT_END(_name) \
} _name ## EventArgs; \
DEFINE_EVENT_HANDLER(_name); \
DEFINE_EVENT_RAISE(_name); \
DEFINE_EVENT_SUBSCRIBE(_name); \
DEFINE_EVENT_UNSUBSCRIBE(_name);
DEFINE_EVENT_RAISE(_name) \
DEFINE_EVENT_SUBSCRIBE(_name) \
DEFINE_EVENT_UNSUBSCRIBE(_name)
#define DEFINE_EVENT_ENTRY(_name) \
{ #_name, { sizeof( _name ## EventArgs) }, 0, { \

View File

@ -156,7 +156,7 @@
/* Mac OS X (__MACOSX__) */
#if (__APPLE__ && __MACH__)
#if (defined(__APPLE__) && defined(__MACH__))
#ifndef __MACOSX__
#define __MACOSX__ 1
#endif
@ -164,7 +164,7 @@
/* iOS (__IOS__)*/
#if (__APPLE__ && TARGET_OS_IPHONE)
#if (defined(__APPLE__) && defined(TARGET_OS_IPHONE))
#ifndef __IOS__
#define __IOS__ 1
#endif

View File

@ -48,8 +48,7 @@ BOOL CloseHandle(HANDLE hObject)
WINPR_THREAD* thread;
thread = (WINPR_THREAD*) Object;
free(Object);
free(thread);
return TRUE;
}

View File

@ -33,7 +33,7 @@
* Keyboard Type 4
*/
DWORD KBD4T[128] =
static DWORD KBD4T[128] =
{
KBD4_T00,
KBD4_T01,
@ -165,7 +165,7 @@ DWORD KBD4T[128] =
KBD4_T7F
};
DWORD KBD4X[128] =
static DWORD KBD4X[128] =
{
VK_NONE,
VK_NONE,
@ -301,7 +301,7 @@ DWORD KBD4X[128] =
* Keyboard Type 7
*/
DWORD KBD7T[128] =
static DWORD KBD7T[128] =
{
KBD7_T00,
KBD7_T01,
@ -433,7 +433,7 @@ DWORD KBD7T[128] =
KBD7_T7F
};
DWORD KBD7X[128] =
static DWORD KBD7X[128] =
{
VK_NONE,
VK_NONE,

View File

@ -437,7 +437,7 @@ char* GetVirtualKeyName(DWORD vkcode)
DWORD GetVirtualKeyCodeFromName(const char* vkname)
{
int i;
unsigned long i;
for (i = 0; i < ARRAYSIZE(VIRTUAL_KEY_CODE_TABLE); i++)
{
@ -453,7 +453,7 @@ DWORD GetVirtualKeyCodeFromName(const char* vkname)
DWORD GetVirtualKeyCodeFromXkbKeyName(const char* xkbname)
{
int i;
unsigned long i;
for (i = 0; i < ARRAYSIZE(XKB_KEYNAME_TABLE); i++)
{

View File

@ -290,6 +290,7 @@ char* GetCombinedPath(char* basePath, char* subPath)
if (!path)
return NULL;
if (basePath)
CopyMemory(path, basePath, basePathLength);
path[basePathLength] = '\0';

View File

@ -55,6 +55,11 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesWritten == 0))
{
printf("Client NamedPipe WriteFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -68,6 +73,10 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesRead == 0))
{
printf("Client NamedPipe ReadFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -120,6 +129,8 @@ static void* named_pipe_server_thread(void* arg)
if (!fConnected)
{
printf("ConnectNamedPipe failure\n");
CloseHandle(hNamedPipe);
return NULL;
}
@ -136,6 +147,10 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesRead == 0))
{
printf("Server NamedPipe ReadFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -152,6 +167,10 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess || (lpNumberOfBytesWritten == 0))
{
printf("Server NamedPipe WriteFile failure\n");
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
return NULL;
}
@ -176,6 +195,9 @@ int TestPipeCreateNamedPipe(int argc, char* argv[])
WaitForSingleObject(ClientThread, INFINITE);
WaitForSingleObject(ServerThread, INFINITE);
CloseHandle(ClientThread);
CloseHandle(ServerThread);
return 0;
}

View File

@ -63,6 +63,11 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess)
{
printf("Client NamedPipe WriteFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -85,6 +90,11 @@ static void* named_pipe_client_thread(void* arg)
if (!fSuccess)
{
printf("Client NamedPipe ReadFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -160,6 +170,10 @@ static void* named_pipe_server_thread(void* arg)
if (!fConnected)
{
printf("ConnectNamedPipe failure: %d\n", GetLastError());
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -178,6 +192,12 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess)
{
printf("Server NamedPipe ReadFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}
@ -203,6 +223,13 @@ static void* named_pipe_server_thread(void* arg)
if (!fSuccess)
{
printf("Server NamedPipe WriteFile failure: %d\n", GetLastError());
free(lpReadBuffer);
free(lpWriteBuffer);
CloseHandle(hNamedPipe);
CloseHandle(hEvent);
return NULL;
}

View File

@ -140,10 +140,13 @@ void sspi_ContextBufferAllocTableNew()
void sspi_ContextBufferAllocTableGrow()
{
size_t size;
ContextBufferAllocTable.entries = NULL;
ContextBufferAllocTable.cEntries = 0;
ContextBufferAllocTable.cMaxEntries *= 2;
size = sizeof(CONTEXT_BUFFER_ALLOC_ENTRY) * ContextBufferAllocTable.cMaxEntries;
if (!size)
return;
ContextBufferAllocTable.entries = realloc(ContextBufferAllocTable.entries, size);
ZeroMemory((void*) &ContextBufferAllocTable.entries[ContextBufferAllocTable.cMaxEntries / 2], size / 2);

View File

@ -90,7 +90,7 @@ defined(__OpenBSD__) || defined(__DragonFly__)
#include <sys/sysctl.h>
#endif
DWORD GetProcessorArchitecture()
static DWORD GetProcessorArchitecture()
{
DWORD cpuArch = PROCESSOR_ARCHITECTURE_UNKNOWN;
@ -113,7 +113,7 @@ DWORD GetProcessorArchitecture()
return cpuArch;
}
DWORD GetNumberOfProcessors()
static DWORD GetNumberOfProcessors()
{
DWORD numCPUs = 1;

View File

@ -248,7 +248,7 @@ void ListDictionary_Remove(wListDictionary* listDictionary, void* key)
void* ListDictionary_GetItemValue(wListDictionary* listDictionary, void* key)
{
void* value = NULL;
wListDictionaryItem* item;
wListDictionaryItem* item = NULL;
if (listDictionary->synchronized)
EnterCriticalSection(&listDictionary->lock);