warnings shown by clang as well as some compiler warnings.
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];
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++)
{
DEBUG_SCARD("Failure: %s (0x%08x)",
pcsc_stringify_error(status), (unsigned) status);
+ free(readerStates);
+ free(pAtrMasks);
return smartcard_output_return(irp, status);
}
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);
smartcard_output_alignment(irp, 8);
free(readerStates);
+ free(pAtrMasks);
return status;
}
* limitations under the License.
*/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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;
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;
fd_set wfds_set;
rdpChannels* channels;
- ZeroMemory(rfds, sizeof(rfds));
- ZeroMemory(wfds, sizeof(wfds));
-
channels = instance->context->channels;
freerdp_connect(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");
LPSTR tmp = NULL;
-LPCSTR tr_esc_str(LPCSTR arg)
+LPSTR tr_esc_str(LPSTR arg)
{
size_t cs = 0, x, ds;
size_t s;
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.");
{
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.");
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.");
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.");
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.");
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.");
}
}
-void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChangeEventArgs* e)
+static void xf_ScalingFactorChangeEventHandler(rdpContext* context, ScalingFactorChangeEventArgs* e)
{
xfContext* xfc = (xfContext*) context;
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);
* 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;
return 0;
}
-int xfreerdp_client_stop(rdpContext* context)
+static int xfreerdp_client_stop(rdpContext* context)
{
xfContext* xfc = (xfContext*) context;
return 0;
}
-int xfreerdp_client_new(freerdp* instance, rdpContext* context)
+static int xfreerdp_client_new(freerdp* instance, rdpContext* context)
{
xfContext* xfc;
rdpSettings* settings;
return 0;
}
-void xfreerdp_client_free(freerdp* instance, rdpContext* context)
+static void xfreerdp_client_free(freerdp* instance, rdpContext* context)
{
xfContext* xfc = (xfContext*) context;
#include "config.h"
#endif
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
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;
*/
/* how may bits do we need to get? */
+ assert(bits_left <= 32);
tmp = 32 - bits_left;
while (tmp)
{
/* 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)
*/
/* how may bits do we need to get? */
+ assert(bits_left <= 32);
+ assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
{
/* 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)
*/
/* how may bits do we need to get? */
+ assert(bits_left <= 32);
+ assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
{
/* 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)
*/
/* how may bits do we need to get? */
+ assert(bits_left <= 32);
+ assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
{
/* 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)
*/
/* how may bits do we need to get? */
+ assert(bits_left <= 32);
+ assert(cur_bits_left <= bits_left);
tmp = 32 - bits_left;
while (tmp)
{
/* 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)
#include "config.h"
#endif
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
if (context->priv->UseThreads)
{
+ assert(params);
+
params[i].context = context;
params[i].tile = message->tiles[i];
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)
{
- work_objects = (PTP_WORK*) malloc(sizeof(PTP_WORK) * message->numTiles);
+ if (message->numTiles)
+ work_objects = (PTP_WORK*) malloc(sizeof(PTP_WORK) * message->numTiles);
if (!work_objects)
{
free(message);
if (context->priv->UseThreads)
{
+ assert(params);
+
params[i].context = context;
params[i].tile = tile;
}
http_response->count = count;
- http_response->lines = (char**) malloc(sizeof(char*) * http_response->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");
{
fprintf(stderr, "Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT\n",
versionCaps->tsgHeader.ComponentId);
+ free(packetCapsResponse);
+ free(versionCaps);
+ free(packet);
return FALSE;
}
free(tsgCaps);
free(versionCaps);
free(packetCapsResponse);
+ free(packet);
return FALSE;
}
{
fprintf(stderr, "Unexpected ComponentId: 0x%04X, Expected TS_GATEWAY_TRANSPORT\n",
versionCaps->tsgHeader.ComponentId);
+ free(versionCaps);
+ free(packetQuarEncResponse);
free(packet);
return FALSE;
}
/* colorTable */
if (icon_info->colorTable == NULL)
- icon_info->colorTable = (BYTE*) malloc(icon_info->cbColorTable);
- else
+ {
+ if (icon_info->cbColorTable)
+ icon_info->colorTable = (BYTE*) malloc(icon_info->cbColorTable);
+ }
+ 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 */
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;
return NULL;
num_subject_alt_names = sk_GENERAL_NAME_num(subject_alt_names);
- strings = (char**) malloc(sizeof(char*) * num_subject_alt_names);
- *lengths = (int*) malloc(sizeof(int*) * 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);
+ }
for (index = 0; index < num_subject_alt_names; ++index)
{
#include "config.h"
#endif
+#include <assert.h>
+
#include <winpr/crt.h>
#include <winpr/sspi.h>
{
int index;
+ assert(NULL != hostname);
+ assert(NULL != common_name);
+
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
fprintf(stderr, "@ WARNING: CERTIFICATE NAME MISMATCH! @\n");
fprintf(stderr, "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
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]);
}
}
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));
+ }
}
}
testPeerContext* context;
freerdp_peer* client = (freerdp_peer*) arg;
- memset(rfds, 0, sizeof(rfds));
-
test_peer_init(client);
/* Initialize the real server settings here */
{
rcount = 0;
+ memset(rfds, 0, sizeof(rfds));
if (client->GetFileDescriptor(client, rfds, &rcount) != TRUE)
{
printf("Failed to get FreeRDP file descriptor\n");
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");
xfServer* server;
freerdp_listener* listener;
- ZeroMemory(rfds, sizeof(rfds));
-
server = (xfServer*) param;
listener = server->listener;
{
rcount = 0;
+ ZeroMemory(rfds, sizeof(rfds));
if (listener->GetFileDescriptor(listener, rfds, &rcount) != TRUE)
{
fprintf(stderr, "Failed to get FreeRDP file descriptor\n");
#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, { \
/* Mac OS X (__MACOSX__) */
-#if (__APPLE__ && __MACH__)
+#if (defined(__APPLE__) && defined(__MACH__))
#ifndef __MACOSX__
#define __MACOSX__ 1
#endif
/* iOS (__IOS__)*/
-#if (__APPLE__ && TARGET_OS_IPHONE)
+#if (defined(__APPLE__) && defined(TARGET_OS_IPHONE))
#ifndef __IOS__
#define __IOS__ 1
#endif
WINPR_THREAD* thread;
thread = (WINPR_THREAD*) Object;
-
- free(Object);
+ free(thread);
return TRUE;
}
* Keyboard Type 4
*/
-DWORD KBD4T[128] =
+static DWORD KBD4T[128] =
{
KBD4_T00,
KBD4_T01,
KBD4_T7F
};
-DWORD KBD4X[128] =
+static DWORD KBD4X[128] =
{
VK_NONE,
VK_NONE,
* Keyboard Type 7
*/
-DWORD KBD7T[128] =
+static DWORD KBD7T[128] =
{
KBD7_T00,
KBD7_T01,
KBD7_T7F
};
-DWORD KBD7X[128] =
+static DWORD KBD7X[128] =
{
VK_NONE,
VK_NONE,
DWORD GetVirtualKeyCodeFromName(const char* vkname)
{
- int i;
+ unsigned long i;
for (i = 0; i < ARRAYSIZE(VIRTUAL_KEY_CODE_TABLE); i++)
{
DWORD GetVirtualKeyCodeFromXkbKeyName(const char* xkbname)
{
- int i;
+ unsigned long i;
for (i = 0; i < ARRAYSIZE(XKB_KEYNAME_TABLE); i++)
{
if (!path)
return NULL;
- CopyMemory(path, basePath, basePathLength);
+ if (basePath)
+ CopyMemory(path, basePath, basePathLength);
path[basePathLength] = '\0';
PathCchConvertStyleA(path, basePathLength, PATH_STYLE_NATIVE);
if (!fSuccess || (lpNumberOfBytesWritten == 0))
{
printf("Client NamedPipe WriteFile failure\n");
+
+ free(lpReadBuffer);
+ free(lpWriteBuffer);
+
+ CloseHandle(hNamedPipe);
return NULL;
}
if (!fSuccess || (lpNumberOfBytesRead == 0))
{
printf("Client NamedPipe ReadFile failure\n");
+ free(lpReadBuffer);
+ free(lpWriteBuffer);
+
+ CloseHandle(hNamedPipe);
return NULL;
}
if (!fConnected)
{
printf("ConnectNamedPipe failure\n");
+
+ CloseHandle(hNamedPipe);
return NULL;
}
if (!fSuccess || (lpNumberOfBytesRead == 0))
{
printf("Server NamedPipe ReadFile failure\n");
+ free(lpReadBuffer);
+ free(lpWriteBuffer);
+
+ CloseHandle(hNamedPipe);
return NULL;
}
if (!fSuccess || (lpNumberOfBytesWritten == 0))
{
printf("Server NamedPipe WriteFile failure\n");
+ free(lpReadBuffer);
+ free(lpWriteBuffer);
+
+ CloseHandle(hNamedPipe);
return NULL;
}
WaitForSingleObject(ClientThread, INFINITE);
WaitForSingleObject(ServerThread, INFINITE);
+ CloseHandle(ClientThread);
+ CloseHandle(ServerThread);
+
return 0;
}
if (!fSuccess)
{
printf("Client NamedPipe WriteFile failure: %d\n", GetLastError());
+ free(lpReadBuffer);
+ free(lpWriteBuffer);
+
+ CloseHandle(hNamedPipe);
+ CloseHandle(hEvent);
return NULL;
}
if (!fSuccess)
{
printf("Client NamedPipe ReadFile failure: %d\n", GetLastError());
+ free(lpReadBuffer);
+ free(lpWriteBuffer);
+
+ CloseHandle(hNamedPipe);
+ CloseHandle(hEvent);
return NULL;
}
if (!fConnected)
{
printf("ConnectNamedPipe failure: %d\n", GetLastError());
+
+ CloseHandle(hNamedPipe);
+ CloseHandle(hEvent);
+
return NULL;
}
if (!fSuccess)
{
printf("Server NamedPipe ReadFile failure: %d\n", GetLastError());
+ free(lpReadBuffer);
+ free(lpWriteBuffer);
+
+ CloseHandle(hNamedPipe);
+ CloseHandle(hEvent);
+
return NULL;
}
if (!fSuccess)
{
printf("Server NamedPipe WriteFile failure: %d\n", GetLastError());
+
+ free(lpReadBuffer);
+ free(lpWriteBuffer);
+
+ CloseHandle(hNamedPipe);
+ CloseHandle(hEvent);
+
return NULL;
}
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);
#include <sys/sysctl.h>
#endif
-DWORD GetProcessorArchitecture()
+static DWORD GetProcessorArchitecture()
{
DWORD cpuArch = PROCESSOR_ARCHITECTURE_UNKNOWN;
return cpuArch;
}
-DWORD GetNumberOfProcessors()
+static DWORD GetNumberOfProcessors()
{
DWORD numCPUs = 1;
void* ListDictionary_GetItemValue(wListDictionary* listDictionary, void* key)
{
void* value = NULL;
- wListDictionaryItem* item;
+ wListDictionaryItem* item = NULL;
if (listDictionary->synchronized)
EnterCriticalSection(&listDictionary->lock);