diff --git a/channels/audin/client/alsa/audin_alsa.c b/channels/audin/client/alsa/audin_alsa.c index 4af683367..80532460d 100644 --- a/channels/audin/client/alsa/audin_alsa.c +++ b/channels/audin/client/alsa/audin_alsa.c @@ -188,10 +188,13 @@ static void* audin_alsa_thread_func(void* arg) rbytes_per_frame = alsa->actual_channels * alsa->bytes_per_channel; tbytes_per_frame = alsa->target_channels * alsa->bytes_per_channel; - alsa->buffer = (BYTE*) xzalloc(tbytes_per_frame * alsa->frames_per_packet); + alsa->buffer = (BYTE*) malloc(tbytes_per_frame * alsa->frames_per_packet); + ZeroMemory(alsa->buffer, tbytes_per_frame * alsa->frames_per_packet); alsa->buffer_frames = 0; - buffer = (BYTE*) xzalloc(rbytes_per_frame * alsa->frames_per_packet); + buffer = (BYTE*) malloc(rbytes_per_frame * alsa->frames_per_packet); + ZeroMemory(buffer, rbytes_per_frame * alsa->frames_per_packet); freerdp_dsp_context_reset_adpcm(alsa->dsp_context); + do { if ((error = snd_pcm_open(&capture_handle, alsa->device_name, SND_PCM_STREAM_CAPTURE, 0)) < 0) diff --git a/channels/audin/client/audin_main.c b/channels/audin/client/audin_main.c index 6a01ccd51..08404f104 100644 --- a/channels/audin/client/audin_main.c +++ b/channels/audin/client/audin_main.c @@ -138,7 +138,8 @@ static int audin_process_formats(IWTSVirtualChannelCallback* pChannelCallback, S } stream_seek_UINT32(s); /* cbSizeFormatsPacket */ - callback->formats = (audinFormat*) xzalloc(NumFormats * sizeof(audinFormat)); + callback->formats = (audinFormat*) malloc(NumFormats * sizeof(audinFormat)); + ZeroMemory(callback->formats, NumFormats * sizeof(audinFormat)); out = stream_new(9); stream_seek(out, 9); diff --git a/channels/audin/client/pulse/audin_pulse.c b/channels/audin/client/pulse/audin_pulse.c index edd721883..1f4873b74 100644 --- a/channels/audin/client/pulse/audin_pulse.c +++ b/channels/audin/client/pulse/audin_pulse.c @@ -425,7 +425,8 @@ static void audin_pulse_open(IAudinDevice* device, AudinReceive receive, void* u if (state == PA_STREAM_READY) { freerdp_dsp_context_reset_adpcm(pulse->dsp_context); - pulse->buffer = xzalloc(pulse->bytes_per_frame * pulse->frames_per_packet); + pulse->buffer = malloc(pulse->bytes_per_frame * pulse->frames_per_packet); + ZeroMemory(pulse->buffer, pulse->bytes_per_frame * pulse->frames_per_packet); pulse->buffer_frames = 0; DEBUG_DVC("connected"); } diff --git a/channels/audin/server/audin.c b/channels/audin/server/audin.c index 8ed36382b..2e0145238 100644 --- a/channels/audin/server/audin.c +++ b/channels/audin/server/audin.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include #include @@ -134,7 +136,9 @@ static BOOL audin_server_recv_formats(audin_server* audin, STREAM* s, UINT32 len if (audin->context.num_client_formats <= 0) return FALSE; - audin->context.client_formats = xzalloc(audin->context.num_client_formats * sizeof(rdpsndFormat)); + audin->context.client_formats = malloc(audin->context.num_client_formats * sizeof(rdpsndFormat)); + ZeroMemory(audin->context.client_formats, audin->context.num_client_formats * sizeof(rdpsndFormat)); + for (i = 0; i < audin->context.num_client_formats; i++) { if (length < 18) @@ -410,7 +414,9 @@ audin_server_context* audin_server_context_new(WTSVirtualChannelManager* vcm) { audin_server* audin; - audin = xnew(audin_server); + audin = (audin_server*) malloc(sizeof(audin_server)); + ZeroMemory(audin, sizeof(audin_server)); + audin->context.vcm = vcm; audin->context.selected_client_format = -1; audin->context.frames_per_packet = 4096; @@ -428,9 +434,12 @@ void audin_server_context_free(audin_server_context* context) audin_server* audin = (audin_server*) context; audin_server_close(context); + if (audin->dsp_context) freerdp_dsp_context_free(audin->dsp_context); + if (audin->context.client_formats) free(audin->context.client_formats); + free(audin); } diff --git a/channels/printer/client/printer_cups.c b/channels/printer/client/printer_cups.c index 08c9f1483..2384b5f4e 100644 --- a/channels/printer/client/printer_cups.c +++ b/channels/printer/client/printer_cups.c @@ -242,13 +242,16 @@ static rdpPrinter** printer_cups_enum_printers(rdpPrinterDriver* driver) int i; num_dests = cupsGetDests(&dests); - printers = (rdpPrinter**)xzalloc(sizeof(rdpPrinter*) * (num_dests + 1)); + printers = (rdpPrinter**) malloc(sizeof(rdpPrinter*) * (num_dests + 1)); + ZeroMemory(printers, sizeof(rdpPrinter*) * (num_dests + 1)); + num_printers = 0; + for (i = 0, dest = dests; i < num_dests; i++, dest++) { if (dest->instance == NULL) { - printers[num_printers++] = printer_cups_new_printer((rdpCupsPrinterDriver*)driver, + printers[num_printers++] = printer_cups_new_printer((rdpCupsPrinterDriver*) driver, dest->name, dest->is_default); } } diff --git a/channels/printer/client/printer_win.c b/channels/printer/client/printer_win.c index 787de648c..fc0a92335 100644 --- a/channels/printer/client/printer_win.c +++ b/channels/printer/client/printer_win.c @@ -142,31 +142,33 @@ static rdpPrintJob* printer_win_create_printjob(rdpPrinter* printer, UINT32 id) win_printer->printjob = win_printjob; - return (rdpPrintJob*)win_printjob; + return (rdpPrintJob*) win_printjob; } static rdpPrintJob* printer_win_find_printjob(rdpPrinter* printer, UINT32 id) { rdpWinPrinter* win_printer = (rdpWinPrinter*)printer; - DEBUG_WINPR(""); + DEBUG_WINPR(""); if (win_printer->printjob == NULL) return NULL; + if (win_printer->printjob->printjob.id != id) return NULL; - return (rdpPrintJob*)win_printer->printjob; + return (rdpPrintJob*) win_printer->printjob; } static void printer_win_free_printer(rdpPrinter* printer) { rdpWinPrinter* win_printer = (rdpWinPrinter*)printer; - DEBUG_WINPR(""); + DEBUG_WINPR(""); if (win_printer->printjob) - win_printer->printjob->printjob.Close((rdpPrintJob*)win_printer->printjob); + win_printer->printjob->printjob.Close((rdpPrintJob*) win_printer->printjob); + free(printer->name); free(printer); } @@ -174,7 +176,7 @@ static void printer_win_free_printer(rdpPrinter* printer) static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, const char* name, const wchar_t* drivername, BOOL is_default) { rdpWinPrinter* win_printer; - wchar_t wname[256]; + wchar_t wname[256]; DWORD needed; PRINTER_INFO_2 *prninfo=NULL; size_t charsConverted; @@ -190,7 +192,7 @@ static rdpPrinter* printer_win_new_printer(rdpWinPrinterDriver* win_driver, cons win_printer->printer.FindPrintJob = printer_win_find_printjob; win_printer->printer.Free = printer_win_free_printer; - swprintf(wname, 256, L"%hs", name); + swprintf(wname, 256, L"%hs", name); OpenPrinter(wname, &(win_printer->hPrinter), NULL); DEBUG_WINPR("handle: 0x%08X", win_printer->hPrinter); @@ -211,31 +213,30 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver) int i; char pname[1000]; size_t charsConverted; - - PRINTER_INFO_2 *prninfo=NULL; - DWORD needed, returned; + PRINTER_INFO_2* prninfo = NULL; + DWORD needed, returned; - DEBUG_WINPR(""); + DEBUG_WINPR(""); + + /* find required size for the buffer */ + EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, NULL, 0, &needed, &returned); - //find required size for the buffer - EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, NULL, 0, &needed, &returned); - - - //allocate array of PRINTER_INFO structures - prninfo = (PRINTER_INFO_2*) GlobalAlloc(GPTR,needed); + /* allocate array of PRINTER_INFO structures */ + prninfo = (PRINTER_INFO_2*) GlobalAlloc(GPTR,needed); - //call again - if ( !EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, (LPBYTE) prninfo, needed, &needed, &returned) ) { + /* call again */ + if ( !EnumPrinters(PRINTER_ENUM_LOCAL|PRINTER_ENUM_CONNECTIONS, NULL, 2, (LPBYTE) prninfo, needed, &needed, &returned) ) + { DEBUG_WINPR("EnumPrinters failed"); - - } ; /* eRROR... */ + } ; /* ERROR... */ DEBUG_WINPR("printers found: %d", returned); + printers = (rdpPrinter**) malloc(sizeof(rdpPrinter*) * (returned + 1)); + ZeroMemory(printers, sizeof(rdpPrinter*) * (returned + 1)); - printers = (rdpPrinter**)xzalloc(sizeof(rdpPrinter*) * (returned + 1)); - num_printers = 0; + num_printers = 0; for (i = 0; i < (int)returned; i++) { diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index af1f2175c..93ec5418b 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -195,7 +195,8 @@ static void rdpsnd_process_message_formats(rdpsndPlugin* rdpsnd, STREAM* data_in return; } - out_formats = (rdpsndFormat*)xzalloc(wNumberOfFormats * sizeof(rdpsndFormat)); + out_formats = (rdpsndFormat*) malloc(wNumberOfFormats * sizeof(rdpsndFormat)); + ZeroMemory(out_formats, wNumberOfFormats * sizeof(rdpsndFormat)); n_out_formats = 0; data_out = stream_new(24); diff --git a/channels/serial/client/serial_tty.c b/channels/serial/client/serial_tty.c index c5761f26b..1a6161244 100644 --- a/channels/serial/client/serial_tty.c +++ b/channels/serial/client/serial_tty.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -467,31 +469,40 @@ SERIAL_TTY* serial_tty_new(const char* path, UINT32 id) { SERIAL_TTY* tty; - tty = xnew(SERIAL_TTY); + tty = (SERIAL_TTY*) malloc(sizeof(SERIAL_TTY)); + ZeroMemory(tty, sizeof(SERIAL_TTY)); + tty->id = id; tty->fd = open(path, O_RDWR | O_NOCTTY | O_NONBLOCK); + if (tty->fd < 0) { perror("open"); DEBUG_WARN("failed to open device %s", path); - serial_tty_free(tty) ; + serial_tty_free(tty); return NULL; } else + { DEBUG_SVC("tty fd %d successfully opened", tty->fd); + } + + tty->ptermios = (struct termios*) malloc(sizeof(struct termios)); + ZeroMemory(tty->ptermios, sizeof(struct termios)); - tty->ptermios = (struct termios*) xzalloc(sizeof(struct termios)); if (tty->ptermios == NULL) { - serial_tty_free(tty) ; + serial_tty_free(tty); return NULL ; } - tty->pold_termios = (struct termios*) xzalloc(sizeof(struct termios)); + tty->pold_termios = (struct termios*) malloc(sizeof(struct termios)); + ZeroMemory(tty->pold_termios, sizeof(struct termios)); + if (tty->pold_termios == NULL) { - serial_tty_free(tty) ; - return NULL ; + serial_tty_free(tty); + return NULL; } tcgetattr(tty->fd, tty->pold_termios); @@ -499,7 +510,7 @@ SERIAL_TTY* serial_tty_new(const char* path, UINT32 id) { DEBUG_WARN("%s access denied", path); fflush(stdout); - serial_tty_free(tty) ; + serial_tty_free(tty); return NULL; } @@ -976,6 +987,7 @@ static UINT32 tty_write_data(SERIAL_TTY* tty, BYTE* data, int len) DEBUG_SVC("in"); r = write(tty->fd, data, len); + if (r < 0) return tty_get_error_status(); diff --git a/channels/smartcard/client/scard_operations.c b/channels/smartcard/client/scard_operations.c index c0c07e990..c533987c8 100644 --- a/channels/smartcard/client/scard_operations.c +++ b/channels/smartcard/client/scard_operations.c @@ -37,6 +37,8 @@ #include #undef BOOL +#include + #include #include #include @@ -438,11 +440,12 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide) (unsigned) hContext, (unsigned) dwTimeout, (int) readerCount); if (readerCount > 0) { - readerStates = xzalloc(readerCount * sizeof(SCARD_READERSTATE)); + readerStates = malloc(readerCount * sizeof(SCARD_READERSTATE)); + ZeroMemory(readerStates, readerCount * sizeof(SCARD_READERSTATE)); + if (!readerStates) return sc_output_return(irp, SCARD_E_NO_MEMORY); - for (i = 0; i < readerCount; i++) { cur = &readerStates[i]; @@ -1226,7 +1229,8 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide) stream_read_UINT32(irp->input, readerCount); - readerStates = xzalloc(readerCount * sizeof(SCARD_READERSTATE)); + readerStates = malloc(readerCount * sizeof(SCARD_READERSTATE)); + ZeroMemory(readerStates, readerCount * sizeof(SCARD_READERSTATE)); if (!readerStates) return sc_output_return(irp, SCARD_E_NO_MEMORY); diff --git a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c index 6d93f82be..6effab9da 100644 --- a/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c +++ b/channels/tsmf/client/ffmpeg/tsmf_ffmpeg.c @@ -27,7 +27,6 @@ #include -#include #include #include #include @@ -146,7 +145,8 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP /* The extradata format that FFmpeg uses is following CodecPrivate in Matroska. See http://haali.su/mkv/codecs.pdf */ mdecoder->codec_context->extradata_size = media_type->ExtraDataSize + 8; - mdecoder->codec_context->extradata = xzalloc(mdecoder->codec_context->extradata_size); + mdecoder->codec_context->extradata = malloc(mdecoder->codec_context->extradata_size); + ZeroMemory(mdecoder->codec_context->extradata, mdecoder->codec_context->extradata_size); p = mdecoder->codec_context->extradata; *p++ = 1; /* Reserved? */ *p++ = media_type->ExtraData[8]; /* Profile */ @@ -167,7 +167,8 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP { /* Add a padding to avoid invalid memory read in some codec */ mdecoder->codec_context->extradata_size = media_type->ExtraDataSize + 8; - mdecoder->codec_context->extradata = xzalloc(mdecoder->codec_context->extradata_size); + mdecoder->codec_context->extradata = malloc(mdecoder->codec_context->extradata_size); + ZeroMemory(mdecoder->codec_context->extradata, mdecoder->codec_context->extradata_size); memcpy(mdecoder->codec_context->extradata, media_type->ExtraData, media_type->ExtraDataSize); memset(mdecoder->codec_context->extradata + media_type->ExtraDataSize, 0, 8); } @@ -307,13 +308,14 @@ static BOOL tsmf_ffmpeg_decode_video(ITSMFDecoder* decoder, const BYTE* data, UI mdecoder->decoded_size = avpicture_get_size(mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width, mdecoder->codec_context->height); - mdecoder->decoded_data = xzalloc(mdecoder->decoded_size); + mdecoder->decoded_data = malloc(mdecoder->decoded_size); + ZeroMemory(mdecoder->decoded_data, mdecoder->decoded_size); frame = avcodec_alloc_frame(); - avpicture_fill((AVPicture *) frame, mdecoder->decoded_data, + avpicture_fill((AVPicture*) frame, mdecoder->decoded_data, mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width, mdecoder->codec_context->height); - av_picture_copy((AVPicture *) frame, (AVPicture *) mdecoder->frame, + av_picture_copy((AVPicture*) frame, (AVPicture*) mdecoder->frame, mdecoder->codec_context->pix_fmt, mdecoder->codec_context->width, mdecoder->codec_context->height); @@ -347,7 +349,8 @@ static BOOL tsmf_ffmpeg_decode_audio(ITSMFDecoder* decoder, const BYTE* data, UI if (mdecoder->decoded_size_max == 0) mdecoder->decoded_size_max = AVCODEC_MAX_AUDIO_FRAME_SIZE + 16; - mdecoder->decoded_data = xzalloc(mdecoder->decoded_size_max); + mdecoder->decoded_data = malloc(mdecoder->decoded_size_max); + ZeroMemory(mdecoder->decoded_data, mdecoder->decoded_size_max); /* align the memory for SSE2 needs */ dst = (BYTE*) (((uintptr_t) mdecoder->decoded_data + 15) & ~ 0x0F); dst_offset = dst - mdecoder->decoded_data; diff --git a/channels/tsmf/client/tsmf_audio.c b/channels/tsmf/client/tsmf_audio.c index ce4398227..6c7ab2ed6 100644 --- a/channels/tsmf/client/tsmf_audio.c +++ b/channels/tsmf/client/tsmf_audio.c @@ -25,9 +25,6 @@ #include #include -#include -#include - #include "tsmf_audio.h" static ITSMFAudioDevice* tsmf_load_audio_device_by_name(const char* name, const char* device) diff --git a/channels/tsmf/client/tsmf_codec.c b/channels/tsmf/client/tsmf_codec.c index e0d1c8efc..f610c638d 100644 --- a/channels/tsmf/client/tsmf_codec.c +++ b/channels/tsmf/client/tsmf_codec.c @@ -526,4 +526,3 @@ BOOL tsmf_codec_check_media_type(STREAM* s) return ret; } - diff --git a/channels/tsmf/client/tsmf_decoder.c b/channels/tsmf/client/tsmf_decoder.c index dabda3fdc..630154776 100644 --- a/channels/tsmf/client/tsmf_decoder.c +++ b/channels/tsmf/client/tsmf_decoder.c @@ -28,9 +28,6 @@ #include #include -#include -#include - #include "tsmf_types.h" #include "tsmf_constants.h" #include "tsmf_decoder.h" diff --git a/channels/tsmf/client/tsmf_ifman.c b/channels/tsmf/client/tsmf_ifman.c index f33b26f3e..dd92246bf 100644 --- a/channels/tsmf/client/tsmf_ifman.c +++ b/channels/tsmf/client/tsmf_ifman.c @@ -26,7 +26,8 @@ #include #include -#include +#include + #include #include "tsmf_types.h" @@ -65,11 +66,13 @@ int tsmf_ifman_exchange_capability_request(TSMF_IFMAN* ifman) stream_set_pos(ifman->output, pos); stream_read_UINT32(ifman->output, numHostCapabilities); + for (i = 0; i < numHostCapabilities; i++) { stream_read_UINT32(ifman->output, CapabilityType); stream_read_UINT32(ifman->output, cbCapabilityLength); pos = stream_get_pos(ifman->output); + switch (CapabilityType) { case 1: /* Protocol version request */ @@ -128,10 +131,11 @@ static TSMF_PRESENTATION* pexisted = 0; int tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman) { - int error = 0; + int status = 0; TSMF_PRESENTATION* presentation; DEBUG_DVC(""); + if (pexisted) { ifman->output_pending = FALSE; @@ -141,18 +145,21 @@ int tsmf_ifman_on_new_presentation(TSMF_IFMAN* ifman) presentation = tsmf_presentation_new(stream_get_tail(ifman->input), ifman->channel_callback); pexisted = presentation; + if (presentation == NULL) - error = 1; + status = 1; else tsmf_presentation_set_audio_device(presentation, ifman->audio_name, ifman->audio_device); + ifman->output_pending = TRUE; - return error; + + return status; } int tsmf_ifman_add_stream(TSMF_IFMAN* ifman) { UINT32 StreamId; - int error = 0; + int status = 0; TSMF_STREAM* stream; TSMF_PRESENTATION* presentation; @@ -162,17 +169,22 @@ int tsmf_ifman_add_stream(TSMF_IFMAN* ifman) stream_seek(ifman->input, 16); if (presentation == NULL) - error = 1; + { + status = 1; + } else { stream_read_UINT32(ifman->input, StreamId); stream_seek_UINT32(ifman->input); /* numMediaType */ stream = tsmf_stream_new(presentation, StreamId); + if (stream) tsmf_stream_set_format(stream, ifman->decoder_name, ifman->input); } + ifman->output_pending = TRUE; - return error; + + return status; } int tsmf_ifman_set_topology_request(TSMF_IFMAN* ifman) @@ -183,12 +195,13 @@ int tsmf_ifman_set_topology_request(TSMF_IFMAN* ifman) stream_write_UINT32(ifman->output, 1); /* TopologyReady */ stream_write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; + return 0; } int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman) { - int error = 0; + int status = 0; UINT32 StreamId; TSMF_STREAM* stream; TSMF_PRESENTATION* presentation; @@ -199,7 +212,9 @@ int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman) stream_seek(ifman->input, 16); if (presentation == NULL) - error = 1; + { + status = 1; + } else { stream_read_UINT32(ifman->input, StreamId); @@ -207,10 +222,12 @@ int tsmf_ifman_remove_stream(TSMF_IFMAN* ifman) if (stream) tsmf_stream_free(stream); else - error = 1; + status = 1; } + ifman->output_pending = TRUE; - return error; + + return status; } int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman) @@ -220,6 +237,7 @@ int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman) DEBUG_DVC(""); presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + if (presentation) tsmf_presentation_free(presentation); @@ -228,6 +246,7 @@ int tsmf_ifman_shutdown_presentation(TSMF_IFMAN* ifman) stream_check_size(ifman->output, 4); stream_write_UINT32(ifman->output, 0); /* Result */ ifman->output_interface_id = TSMF_INTERFACE_DEFAULT | STREAM_ID_STUB; + return 0; } @@ -335,7 +354,9 @@ int tsmf_ifman_update_geometry_info(TSMF_IFMAN* ifman) { if (num_rects > 0) { - rects = (RDP_RECT*) xzalloc(sizeof(RDP_RECT) * num_rects); + rects = (RDP_RECT*) malloc(sizeof(RDP_RECT) * num_rects); + ZeroMemory(rects, sizeof(RDP_RECT) * num_rects); + for (i = 0; i < num_rects; i++) { stream_read_UINT16(ifman->input, rects[i].y); /* Top */ @@ -402,35 +423,41 @@ int tsmf_ifman_on_sample(TSMF_IFMAN* ifman) (int)ThrottleDuration, SampleExtensions, cbData); presentation = tsmf_presentation_find_by_id(ifman->presentation_id); + if (presentation == NULL) { DEBUG_WARN("unknown presentation id"); return 1; } + stream = tsmf_stream_find_by_id(presentation, StreamId); + if (stream == NULL) { DEBUG_WARN("unknown stream id"); return 1; } + tsmf_stream_push_sample(stream, ifman->channel_callback, ifman->message_id, SampleStartTime, SampleEndTime, ThrottleDuration, SampleExtensions, cbData, stream_get_tail(ifman->input)); ifman->output_pending = TRUE; + return 0; } int tsmf_ifman_on_flush(TSMF_IFMAN* ifman) { - TSMF_PRESENTATION* presentation; UINT32 StreamId; + TSMF_PRESENTATION* presentation; stream_seek(ifman->input, 16); stream_read_UINT32(ifman->input, StreamId); DEBUG_DVC("StreamId %d", StreamId); presentation = tsmf_presentation_find_by_id(ifman->presentation_id); + if (presentation == NULL) { DEBUG_WARN("unknown presentation id"); @@ -440,18 +467,20 @@ int tsmf_ifman_on_flush(TSMF_IFMAN* ifman) tsmf_presentation_flush(presentation); ifman->output_pending = TRUE; + return 0; } int tsmf_ifman_on_end_of_stream(TSMF_IFMAN* ifman) { - TSMF_PRESENTATION* presentation; - TSMF_STREAM* stream; UINT32 StreamId; + TSMF_STREAM* stream; + TSMF_PRESENTATION* presentation; presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); stream_seek(ifman->input, 16); stream_read_UINT32(ifman->input, StreamId); + if (presentation) { stream = tsmf_stream_find_by_id(presentation, StreamId); @@ -477,6 +506,7 @@ int tsmf_ifman_on_playback_started(TSMF_IFMAN* ifman) DEBUG_DVC(""); presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + if (presentation) tsmf_presentation_start(presentation); else @@ -502,10 +532,12 @@ int tsmf_ifman_on_playback_paused(TSMF_IFMAN* ifman) /* Added pause control so gstreamer pipeline can be paused accordingly */ presentation = tsmf_presentation_find_by_id(stream_get_tail(ifman->input)); + if (presentation) tsmf_presentation_paused(presentation); else DEBUG_WARN("unknown presentation id"); + return 0; } @@ -564,4 +596,3 @@ int tsmf_ifman_on_playback_rate_changed(TSMF_IFMAN * ifman) return 0; } - diff --git a/channels/tsmf/client/tsmf_media.c b/channels/tsmf/client/tsmf_media.c index 3438e8a48..340f20bb2 100644 --- a/channels/tsmf/client/tsmf_media.c +++ b/channels/tsmf/client/tsmf_media.c @@ -35,7 +35,8 @@ #include #endif -#include +#include + #include #include #include @@ -271,7 +272,8 @@ TSMF_PRESENTATION* tsmf_presentation_new(const BYTE* guid, IWTSVirtualChannelCal return NULL; } - presentation = xnew(TSMF_PRESENTATION); + presentation = (TSMF_PRESENTATION*) malloc(sizeof(TSMF_PRESENTATION)); + ZeroMemory(presentation, sizeof(TSMF_PRESENTATION)); memcpy(presentation->presentation_id, guid, GUID_SIZE); presentation->channel_callback = pChannelCallback; @@ -364,10 +366,14 @@ static void tsmf_sample_playback_video(TSMF_SAMPLE* sample) free(presentation->last_rects); presentation->last_rects = NULL; } + presentation->last_num_rects = presentation->output_num_rects; + if (presentation->last_num_rects > 0) { - presentation->last_rects = xzalloc(presentation->last_num_rects * sizeof(RDP_RECT)); + presentation->last_rects = malloc(presentation->last_num_rects * sizeof(RDP_RECT)); + ZeroMemory(presentation->last_rects, presentation->last_num_rects * sizeof(RDP_RECT)); + memcpy(presentation->last_rects, presentation->output_rects, presentation->last_num_rects * sizeof(RDP_RECT)); } @@ -384,10 +390,14 @@ static void tsmf_sample_playback_video(TSMF_SAMPLE* sample) vevent->y = presentation->output_y; vevent->width = presentation->output_width; vevent->height = presentation->output_height; + if (presentation->output_num_rects > 0) { vevent->num_visible_rects = presentation->output_num_rects; - vevent->visible_rects = (RDP_RECT*) xzalloc(presentation->output_num_rects * sizeof(RDP_RECT)); + + vevent->visible_rects = (RDP_RECT*) malloc(presentation->output_num_rects * sizeof(RDP_RECT)); + ZeroMemory(vevent->visible_rects, presentation->output_num_rects * sizeof(RDP_RECT)); + memcpy(vevent->visible_rects, presentation->output_rects, presentation->output_num_rects * sizeof(RDP_RECT)); } @@ -567,10 +577,13 @@ static void tsmf_sample_playback(TSMF_SAMPLE* sample) free(presentation->last_rects); presentation->last_rects = NULL; } + presentation->last_num_rects = presentation->output_num_rects; + if (presentation->last_num_rects > 0) { - presentation->last_rects = xzalloc(presentation->last_num_rects * sizeof(RDP_RECT)); + presentation->last_rects = malloc(presentation->last_num_rects * sizeof(RDP_RECT)); + ZeroMemory(presentation->last_rects, presentation->last_num_rects * sizeof(RDP_RECT)); memcpy(presentation->last_rects, presentation->output_rects, presentation->last_num_rects * sizeof(RDP_RECT)); } if(stream->decoder->UpdateRenderingArea) @@ -921,7 +934,8 @@ TSMF_STREAM* tsmf_stream_new(TSMF_PRESENTATION* presentation, UINT32 stream_id) return NULL; } - stream = xnew(TSMF_STREAM); + stream = (TSMF_STREAM*) malloc(sizeof(TSMF_STREAM)); + ZeroMemory(stream, sizeof(TSMF_STREAM)); stream->stream_id = stream_id; stream->presentation = presentation; @@ -1035,7 +1049,8 @@ void tsmf_stream_push_sample(TSMF_STREAM* stream, IWTSVirtualChannelCallback* pC ReleaseMutex(tsmf_mutex); - sample = xnew(TSMF_SAMPLE); + sample = (TSMF_SAMPLE*) malloc(sizeof(TSMF_SAMPLE)); + ZeroMemory(sample, sizeof(TSMF_SAMPLE)); sample->sample_id = sample_id; sample->start_time = start_time; @@ -1045,7 +1060,8 @@ void tsmf_stream_push_sample(TSMF_STREAM* stream, IWTSVirtualChannelCallback* pC sample->stream = stream; sample->channel_callback = pChannelCallback; sample->data_size = data_size; - sample->data = xzalloc(data_size + TSMF_BUFFER_PADDING_SIZE); + sample->data = malloc(data_size + TSMF_BUFFER_PADDING_SIZE); + ZeroMemory(sample->data, data_size + TSMF_BUFFER_PADDING_SIZE); memcpy(sample->data, data, data_size); freerdp_thread_lock(stream->thread); diff --git a/channels/urbdrc/client/urbdrc_main.c b/channels/urbdrc/client/urbdrc_main.c index 6da4710fb..0a1899185 100644 --- a/channels/urbdrc/client/urbdrc_main.c +++ b/channels/urbdrc/client/urbdrc_main.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include @@ -1006,7 +1008,8 @@ static int urbdrc_load_udevman_plugin(IWTSPlugin* pPlugin, const char* name, RDP } else { - fullname = xzalloc(strlen(name) + 8); + fullname = malloc(strlen(name) + 8); + ZeroMemory(fullname, strlen(name) + 8); strcpy(fullname, name); strcat(fullname, "_udevman"); entry = (PFREERDP_URBDRC_DEVICE_ENTRY) freerdp_load_plugin(fullname, URBDRC_UDEVMAN_EXPORT_FUNC_NAME); diff --git a/client/DirectFB/dfreerdp.c b/client/DirectFB/dfreerdp.c index 54c2a0357..e3037267b 100644 --- a/client/DirectFB/dfreerdp.c +++ b/client/DirectFB/dfreerdp.c @@ -29,6 +29,7 @@ #include #include +#include #include #include "df_event.h" @@ -120,7 +121,9 @@ BOOL df_pre_connect(freerdp* instance) dfContext* context; rdpSettings* settings; - dfi = (dfInfo*) xzalloc(sizeof(dfInfo)); + dfi = (dfInfo*) malloc(sizeof(dfInfo)); + ZeroMemory(dfi, sizeof(dfInfo)); + context = ((dfContext*) instance->context); context->dfi = dfi; @@ -474,7 +477,9 @@ int main(int argc, char* argv[]) DirectFBInit(&argc, &argv); freerdp_parse_args(instance->settings, argc, argv, df_process_plugin_args, channels, NULL, NULL); - data = (struct thread_data*) xzalloc(sizeof(struct thread_data)); + data = (struct thread_data*) malloc(sizeof(struct thread_data)); + ZeroMemory(data, sizeof(sizeof(struct thread_data))); + data->instance = instance; g_thread_count++; diff --git a/client/Sample/freerdp.c b/client/Sample/freerdp.c index b92733e6b..b03c49cdb 100644 --- a/client/Sample/freerdp.c +++ b/client/Sample/freerdp.c @@ -43,6 +43,7 @@ #include #include +#include #include struct tf_info @@ -151,7 +152,10 @@ BOOL tf_pre_connect(freerdp* instance) rdpSettings* settings; context = (tfContext*) instance->context; - tfi = (tfInfo*) xzalloc(sizeof(tfInfo)); + + tfi = (tfInfo*) malloc(sizeof(tfInfo)); + ZeroMemory(tfi, sizeof(tfInfo)); + context->tfi = tfi; settings = instance->settings; @@ -328,7 +332,9 @@ int main(int argc, char* argv[]) channels = instance->context->channels; freerdp_parse_args(instance->settings, argc, argv, tf_process_plugin_args, channels, NULL, NULL); - data = (struct thread_data*) xzalloc(sizeof(struct thread_data)); + data = (struct thread_data*) malloc(sizeof(struct thread_data)); + ZeroMemory(data, sizeof(sizeof(struct thread_data))); + data->instance = instance; g_thread_count++; diff --git a/client/Windows/wf_gdi.c b/client/Windows/wf_gdi.c index 334913f04..6fcc51b5d 100644 --- a/client/Windows/wf_gdi.c +++ b/client/Windows/wf_gdi.c @@ -422,7 +422,8 @@ void wf_gdi_surface_bits(rdpContext* context, SURFACE_BITS_COMMAND* surface_bits RFX_CONTEXT* rfx_context = (RFX_CONTEXT*) wfi->rfx_context; NSC_CONTEXT* nsc_context = (NSC_CONTEXT*) wfi->nsc_context; - tile_bitmap = (char*) xzalloc(32); + tile_bitmap = (char*) malloc(32); + ZeroMemory(tile_bitmap, 32); if (surface_bits_command->codecID == CODEC_ID_REMOTEFX) { diff --git a/client/Windows/wfreerdp.c b/client/Windows/wfreerdp.c index 879a0b6d6..926f6ae60 100644 --- a/client/Windows/wfreerdp.c +++ b/client/Windows/wfreerdp.c @@ -154,7 +154,9 @@ BOOL wf_pre_connect(freerdp* instance) wfContext* context; rdpSettings* settings; - wfi = (wfInfo*) xzalloc(sizeof(wfInfo)); + wfi = (wfInfo*) malloc(sizeof(wfInfo)); + ZeroMemory(wfi, sizeof(wfInfo)); + context = (wfContext*) instance->context; wfi->instance = instance; context->wfi = wfi; @@ -206,7 +208,9 @@ BOOL wf_pre_connect(freerdp* instance) wfi->fs_toggle = wfi->fullscreen; wfi->sw_gdi = settings->SoftwareGdi; - wfi->clrconv = (HCLRCONV) xzalloc(sizeof(CLRCONV)); + wfi->clrconv = (HCLRCONV) malloc(sizeof(CLRCONV)); + ZeroMemory(wfi->clrconv, sizeof(CLRCONV)); + wfi->clrconv->palette = NULL; wfi->clrconv->alpha = FALSE; @@ -677,7 +681,9 @@ static DWORD WINAPI thread_func(LPVOID lpParam) data = (thread_data*) lpParam; instance = data->instance; - wfi = (wfInfo*) xzalloc(sizeof(wfInfo)); + wfi = (wfInfo*) malloc(sizeof(wfInfo)); + ZeroMemory(wfi, sizeof(wfInfo)); + ((wfContext*) instance->context)->wfi = wfi; wfi->instance = instance; @@ -789,7 +795,9 @@ INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine int status; int arg_parse_result; - data = (thread_data*) xzalloc(sizeof(thread_data)); + data = (thread_data*) malloc(sizeof(thread_data)); + ZeroMemory(data, sizeof(thread_data)); + data->instance = instance; freerdp_register_addin_provider(freerdp_channels_load_static_addin_entry, 0); diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 67641fece..c12cc26fa 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include #include @@ -80,7 +82,9 @@ void xf_cliprdr_init(xfInfo* xfi, rdpChannels* chanman) UINT32 id; clipboardContext* cb; - cb = xnew(clipboardContext); + cb = (clipboardContext*) malloc(sizeof(clipboardContext)); + ZeroMemory(cb, sizeof(clipboardContext)); + xfi->clipboard_context = cb; cb->channels = chanman; @@ -168,7 +172,9 @@ static BYTE* lf2crlf(BYTE* data, int* size) int out_size; out_size = (*size) * 2 + 1; - outbuf = (BYTE*) xzalloc(out_size); + outbuf = (BYTE*) malloc(out_size); + ZeroMemory(outbuf, out_size); + out = outbuf; in = data; in_end = data + (*size); @@ -561,7 +567,9 @@ static BYTE* xf_cliprdr_process_requested_dib(BYTE* data, int* size) } *size -= 14; - outbuf = (BYTE*) xzalloc(*size); + outbuf = (BYTE*) malloc(*size); + ZeroMemory(outbuf, *size); + memcpy(outbuf, data + 14, *size); return outbuf; @@ -591,11 +599,15 @@ static BYTE* xf_cliprdr_process_requested_html(BYTE* data, int* size) if (inbuf == NULL) { - inbuf = xzalloc(*size + 1); + inbuf = malloc(*size + 1); + ZeroMemory(inbuf, *size + 1); + memcpy(inbuf, data, *size); } - outbuf = (BYTE*) xzalloc(*size + 200); + outbuf = (BYTE*) malloc(*size + 200); + ZeroMemory(outbuf, *size + 200); + strcpy((char*) outbuf, "Version:0.9\r\n" "StartHTML:0000000000\r\n" @@ -604,6 +616,7 @@ static BYTE* xf_cliprdr_process_requested_html(BYTE* data, int* size) "EndFragment:0000000000\r\n"); in = (BYTE*) strstr((char*) inbuf, "xselection.property = None; respond->xselection.type = SelectionNotify; respond->xselection.display = xevent->xselectionrequest.display; diff --git a/client/X11/xf_graphics.c b/client/X11/xf_graphics.c index f3491398d..024d40c2a 100644 --- a/client/X11/xf_graphics.c +++ b/client/X11/xf_graphics.c @@ -28,6 +28,8 @@ #include #endif +#include + #include #include #include @@ -214,7 +216,9 @@ void xf_Pointer_New(rdpContext* context, rdpPointer* pointer) ci.height = pointer->height; ci.xhot = pointer->xPos; ci.yhot = pointer->yPos; - ci.pixels = (XcursorPixel*) xzalloc(ci.width * ci.height * 4); + + ci.pixels = (XcursorPixel*) malloc(ci.width * ci.height * 4); + ZeroMemory(ci.pixels, ci.width * ci.height * 4); if ((pointer->andMaskData != 0) && (pointer->xorMaskData != 0)) { @@ -378,7 +382,9 @@ void xf_register_graphics(rdpGraphics* graphics) rdpPointer* pointer; rdpGlyph* glyph; - bitmap = xnew(rdpBitmap); + bitmap = (rdpBitmap*) malloc(sizeof(rdpBitmap)); + ZeroMemory(bitmap, sizeof(rdpBitmap)); + bitmap->size = sizeof(xfBitmap); bitmap->New = xf_Bitmap_New; @@ -390,7 +396,9 @@ void xf_register_graphics(rdpGraphics* graphics) graphics_register_bitmap(graphics, bitmap); free(bitmap); - pointer = xnew(rdpPointer); + pointer = (rdpPointer*) malloc(sizeof(rdpPointer)); + ZeroMemory(pointer, sizeof(rdpPointer)); + pointer->size = sizeof(xfPointer); pointer->New = xf_Pointer_New; @@ -402,7 +410,9 @@ void xf_register_graphics(rdpGraphics* graphics) graphics_register_pointer(graphics, pointer); free(pointer); - glyph = xnew(rdpGlyph); + glyph = (rdpGlyph*) malloc(sizeof(rdpGlyph)); + ZeroMemory(glyph, sizeof(rdpGlyph)); + glyph->size = sizeof(xfGlyph); glyph->New = xf_Glyph_New; diff --git a/client/X11/xf_monitor.c b/client/X11/xf_monitor.c index 4fdde0036..aad52dd12 100644 --- a/client/X11/xf_monitor.c +++ b/client/X11/xf_monitor.c @@ -27,6 +27,8 @@ #include #include +#include + #ifdef WITH_XINERAMA #include #endif @@ -84,7 +86,8 @@ BOOL xf_detect_monitors(xfInfo* xfi, rdpSettings* settings) if (vscreen->nmonitors > 16) vscreen->nmonitors = 0; - vscreen->monitors = xzalloc(sizeof(MONITOR_INFO) * vscreen->nmonitors); + vscreen->monitors = malloc(sizeof(MONITOR_INFO) * vscreen->nmonitors); + ZeroMemory(vscreen->monitors, sizeof(MONITOR_INFO) * vscreen->nmonitors); if (vscreen->nmonitors) { diff --git a/client/X11/xf_tsmf.c b/client/X11/xf_tsmf.c index 5e59dda5b..66a7769b7 100644 --- a/client/X11/xf_tsmf.c +++ b/client/X11/xf_tsmf.c @@ -33,6 +33,8 @@ #include #include +#include + #include #include #include @@ -77,7 +79,9 @@ void xf_tsmf_init(xfInfo* xfi, long xv_port) XvAttribute* attr; XvImageFormatValues* fo; - xv = xnew(xfXvContext); + xv = (xfXvContext*) malloc(sizeof(xfXvContext)); + ZeroMemory(xv, sizeof(xfXvContext)); + xfi->xv_context = xv; xv->xv_colorkey_atom = None; @@ -142,7 +146,9 @@ void xf_tsmf_init(xfInfo* xfi, long xv_port) fo = XvListImageFormats(xfi->display, xv->xv_port, &ret); if (ret > 0) { - xv->xv_pixfmts = (UINT32*) xzalloc((ret + 1) * sizeof(UINT32)); + xv->xv_pixfmts = (UINT32*) malloc((ret + 1) * sizeof(UINT32)); + ZeroMemory(xv->xv_pixfmts, (ret + 1) * sizeof(UINT32)); + for (i = 0; i < ret; i++) { xv->xv_pixfmts[i] = fo[i].id; diff --git a/client/X11/xf_window.c b/client/X11/xf_window.c index 406808b17..cc1c9f80f 100644 --- a/client/X11/xf_window.c +++ b/client/X11/xf_window.c @@ -33,6 +33,8 @@ #include #include +#include + #include #include @@ -309,7 +311,8 @@ xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, xfWindow* window; XEvent xevent; - window = (xfWindow*) xzalloc(sizeof(xfWindow)); + window = (xfWindow*) malloc(sizeof(xfWindow)); + ZeroMemory(window, sizeof(xfWindow)); if (window != NULL) { @@ -471,7 +474,8 @@ xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, XWMHints* InputModeHint; XClassHint* class_hints; - window = (xfWindow*) xzalloc(sizeof(xfWindow)); + window = (xfWindow*) malloc(sizeof(xfWindow)); + ZeroMemory(window, sizeof(xfWindow)); xf_FixWindowCoordinates(xfi, &x, &y, &width, &height); diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index 5a65fd52b..d9a4ca0f5 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -501,7 +501,9 @@ BOOL xf_pre_connect(freerdp* instance) BOOL bitmap_cache; rdpSettings* settings; - xfi = (xfInfo*) xzalloc(sizeof(xfInfo)); + xfi = (xfInfo*) malloc(sizeof(xfInfo)); + ZeroMemory(xfi, sizeof(xfInfo)); + ((xfContext*) instance->context)->xfi = xfi; xfi->_context = instance->context; @@ -1373,7 +1375,9 @@ int main(int argc, char* argv[]) instance->context->argv = argv; instance->settings->SoftwareGdi = FALSE; - data = (struct thread_data*) xzalloc(sizeof(struct thread_data)); + data = (struct thread_data*) malloc(sizeof(struct thread_data)); + ZeroMemory(data, sizeof(struct thread_data)); + data->instance = instance; g_thread_count++; diff --git a/libfreerdp/cache/bitmap.c b/libfreerdp/cache/bitmap.c index a7a50e5d4..f22916be2 100644 --- a/libfreerdp/cache/bitmap.c +++ b/libfreerdp/cache/bitmap.c @@ -23,6 +23,8 @@ #include +#include + #include #include #include @@ -272,7 +274,8 @@ rdpBitmapCache* bitmap_cache_new(rdpSettings* settings) int i; rdpBitmapCache* bitmap_cache; - bitmap_cache = (rdpBitmapCache*) xzalloc(sizeof(rdpBitmapCache)); + bitmap_cache = (rdpBitmapCache*) malloc(sizeof(rdpBitmapCache)); + ZeroMemory(bitmap_cache, sizeof(rdpBitmapCache)); if (bitmap_cache != NULL) { @@ -282,13 +285,15 @@ rdpBitmapCache* bitmap_cache_new(rdpSettings* settings) bitmap_cache->maxCells = settings->BitmapCacheV2NumCells; - bitmap_cache->cells = (BITMAP_V2_CELL*) xzalloc(sizeof(BITMAP_V2_CELL) * bitmap_cache->maxCells); + bitmap_cache->cells = (BITMAP_V2_CELL*) malloc(sizeof(BITMAP_V2_CELL) * bitmap_cache->maxCells); + ZeroMemory(bitmap_cache->cells, sizeof(BITMAP_V2_CELL) * bitmap_cache->maxCells); for (i = 0; i < (int) bitmap_cache->maxCells; i++) { bitmap_cache->cells[i].number = settings->BitmapCacheV2CellInfo[i].numEntries; /* allocate an extra entry for BITMAP_CACHE_WAITING_LIST_INDEX */ - bitmap_cache->cells[i].entries = (rdpBitmap**) xzalloc(sizeof(rdpBitmap*) * (bitmap_cache->cells[i].number + 1)); + bitmap_cache->cells[i].entries = (rdpBitmap**) malloc(sizeof(rdpBitmap*) * (bitmap_cache->cells[i].number + 1)); + ZeroMemory(bitmap_cache->cells[i].entries, sizeof(rdpBitmap*) * (bitmap_cache->cells[i].number + 1)); } } diff --git a/libfreerdp/cache/brush.c b/libfreerdp/cache/brush.c index f3fd4fbb2..bc0149084 100644 --- a/libfreerdp/cache/brush.c +++ b/libfreerdp/cache/brush.c @@ -23,6 +23,8 @@ #include +#include + #include #include #include @@ -170,7 +172,8 @@ rdpBrushCache* brush_cache_new(rdpSettings* settings) { rdpBrushCache* brush; - brush = (rdpBrushCache*) xzalloc(sizeof(rdpBrushCache)); + brush = (rdpBrushCache*) malloc(sizeof(rdpBrushCache)); + ZeroMemory(brush, sizeof(rdpBrushCache)); if (brush != NULL) { @@ -179,8 +182,11 @@ rdpBrushCache* brush_cache_new(rdpSettings* settings) brush->maxEntries = 64; brush->maxMonoEntries = 64; - brush->entries = (BRUSH_ENTRY*) xzalloc(sizeof(BRUSH_ENTRY) * brush->maxEntries); - brush->monoEntries = (BRUSH_ENTRY*) xzalloc(sizeof(BRUSH_ENTRY) * brush->maxMonoEntries); + brush->entries = (BRUSH_ENTRY*) malloc(sizeof(BRUSH_ENTRY) * brush->maxEntries); + ZeroMemory(brush->entries, sizeof(BRUSH_ENTRY) * brush->maxEntries); + + brush->monoEntries = (BRUSH_ENTRY*) malloc(sizeof(BRUSH_ENTRY) * brush->maxMonoEntries); + ZeroMemory(brush->monoEntries, sizeof(BRUSH_ENTRY) * brush->maxMonoEntries); } return brush; diff --git a/libfreerdp/cache/cache.c b/libfreerdp/cache/cache.c index f2f1a4a70..fac49ff33 100644 --- a/libfreerdp/cache/cache.c +++ b/libfreerdp/cache/cache.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include #include @@ -30,7 +32,8 @@ rdpCache* cache_new(rdpSettings* settings) { rdpCache* cache; - cache = (rdpCache*) xzalloc(sizeof(rdpCache)); + cache = (rdpCache*) malloc(sizeof(rdpCache)); + ZeroMemory(cache, sizeof(rdpCache)); if (cache != NULL) { diff --git a/libfreerdp/cache/glyph.c b/libfreerdp/cache/glyph.c index 32494ce29..efd52dd86 100644 --- a/libfreerdp/cache/glyph.c +++ b/libfreerdp/cache/glyph.c @@ -23,6 +23,8 @@ #include +#include + #include #include #include @@ -455,7 +457,8 @@ rdpGlyphCache* glyph_cache_new(rdpSettings* settings) { rdpGlyphCache* glyph; - glyph = (rdpGlyphCache*) xzalloc(sizeof(rdpGlyphCache)); + glyph = (rdpGlyphCache*) malloc(sizeof(rdpGlyphCache)); + ZeroMemory(glyph, sizeof(rdpGlyphCache)); if (glyph != NULL) { @@ -468,10 +471,12 @@ rdpGlyphCache* glyph_cache_new(rdpSettings* settings) { glyph->glyphCache[i].number = settings->GlyphCache[i].cacheEntries; glyph->glyphCache[i].maxCellSize = settings->GlyphCache[i].cacheMaximumCellSize; - glyph->glyphCache[i].entries = (rdpGlyph**) xzalloc(sizeof(rdpGlyph*) * glyph->glyphCache[i].number); + glyph->glyphCache[i].entries = (rdpGlyph**) malloc(sizeof(rdpGlyph*) * glyph->glyphCache[i].number); + ZeroMemory(glyph->glyphCache[i].entries, sizeof(rdpGlyph*) * glyph->glyphCache[i].number); } - glyph->fragCache.entries = xzalloc(sizeof(FRAGMENT_CACHE_ENTRY) * 256); + glyph->fragCache.entries = malloc(sizeof(FRAGMENT_CACHE_ENTRY) * 256); + ZeroMemory(glyph->fragCache.entries, sizeof(FRAGMENT_CACHE_ENTRY) * 256); } return glyph; diff --git a/libfreerdp/cache/nine_grid.c b/libfreerdp/cache/nine_grid.c index 799d7d434..66701778e 100644 --- a/libfreerdp/cache/nine_grid.c +++ b/libfreerdp/cache/nine_grid.c @@ -23,6 +23,8 @@ #include +#include + #include #include #include @@ -96,7 +98,8 @@ rdpNineGridCache* nine_grid_cache_new(rdpSettings* settings) { rdpNineGridCache* nine_grid; - nine_grid = (rdpNineGridCache*) xzalloc(sizeof(rdpNineGridCache)); + nine_grid = (rdpNineGridCache*) malloc(sizeof(rdpNineGridCache)); + ZeroMemory(nine_grid, sizeof(rdpNineGridCache)); if (nine_grid != NULL) { @@ -108,7 +111,8 @@ rdpNineGridCache* nine_grid_cache_new(rdpSettings* settings) nine_grid->settings->DrawNineGridCacheSize = nine_grid->maxSize; nine_grid->settings->DrawNineGridCacheEntries = nine_grid->maxEntries; - nine_grid->entries = (NINE_GRID_ENTRY*) xzalloc(sizeof(NINE_GRID_ENTRY) * nine_grid->maxEntries); + nine_grid->entries = (NINE_GRID_ENTRY*) malloc(sizeof(NINE_GRID_ENTRY) * nine_grid->maxEntries); + ZeroMemory(nine_grid->entries, sizeof(NINE_GRID_ENTRY) * nine_grid->maxEntries); } return nine_grid; diff --git a/libfreerdp/cache/offscreen.c b/libfreerdp/cache/offscreen.c index 6d9d833ef..f85ad3f3c 100644 --- a/libfreerdp/cache/offscreen.c +++ b/libfreerdp/cache/offscreen.c @@ -23,6 +23,8 @@ #include +#include + #include #include @@ -134,7 +136,8 @@ rdpOffscreenCache* offscreen_cache_new(rdpSettings* settings) { rdpOffscreenCache* offscreen_cache; - offscreen_cache = (rdpOffscreenCache*) xzalloc(sizeof(rdpOffscreenCache)); + offscreen_cache = (rdpOffscreenCache*) malloc(sizeof(rdpOffscreenCache)); + ZeroMemory(offscreen_cache, sizeof(rdpOffscreenCache)); if (offscreen_cache != NULL) { @@ -148,7 +151,8 @@ rdpOffscreenCache* offscreen_cache_new(rdpSettings* settings) settings->OffscreenCacheSize = offscreen_cache->maxSize; settings->OffscreenCacheEntries = offscreen_cache->maxEntries; - offscreen_cache->entries = (rdpBitmap**) xzalloc(sizeof(rdpBitmap*) * offscreen_cache->maxEntries); + offscreen_cache->entries = (rdpBitmap**) malloc(sizeof(rdpBitmap*) * offscreen_cache->maxEntries); + ZeroMemory(offscreen_cache->entries, sizeof(rdpBitmap*) * offscreen_cache->maxEntries); } return offscreen_cache; diff --git a/libfreerdp/cache/palette.c b/libfreerdp/cache/palette.c index 9d093bf26..790111b9b 100644 --- a/libfreerdp/cache/palette.c +++ b/libfreerdp/cache/palette.c @@ -23,6 +23,8 @@ #include +#include + #include #include @@ -75,13 +77,15 @@ rdpPaletteCache* palette_cache_new(rdpSettings* settings) { rdpPaletteCache* palette_cache; - palette_cache = (rdpPaletteCache*) xzalloc(sizeof(rdpPaletteCache)); + palette_cache = (rdpPaletteCache*) malloc(sizeof(rdpPaletteCache)); + ZeroMemory(palette_cache, sizeof(rdpPaletteCache)); if (palette_cache != NULL) { palette_cache->settings = settings; palette_cache->maxEntries = 6; - palette_cache->entries = (PALETTE_TABLE_ENTRY*) xzalloc(sizeof(PALETTE_TABLE_ENTRY) * palette_cache->maxEntries); + palette_cache->entries = (PALETTE_TABLE_ENTRY*) malloc(sizeof(PALETTE_TABLE_ENTRY) * palette_cache->maxEntries); + ZeroMemory(palette_cache->entries, sizeof(PALETTE_TABLE_ENTRY) * palette_cache->maxEntries); } return palette_cache; diff --git a/libfreerdp/cache/pointer.c b/libfreerdp/cache/pointer.c index 6d9ffe3b7..0135d02a2 100644 --- a/libfreerdp/cache/pointer.c +++ b/libfreerdp/cache/pointer.c @@ -23,6 +23,8 @@ #include +#include + #include #include @@ -159,14 +161,18 @@ rdpPointerCache* pointer_cache_new(rdpSettings* settings) { rdpPointerCache* pointer_cache; - pointer_cache = (rdpPointerCache*) xzalloc(sizeof(rdpPointerCache)); + pointer_cache = (rdpPointerCache*) malloc(sizeof(rdpPointerCache)); if (pointer_cache != NULL) { + ZeroMemory(pointer_cache, sizeof(rdpPointerCache)); + pointer_cache->settings = settings; pointer_cache->cacheSize = settings->PointerCacheSize; pointer_cache->update = ((freerdp*) settings->instance)->update; - pointer_cache->entries = (rdpPointer**) xzalloc(sizeof(rdpPointer*) * pointer_cache->cacheSize); + + pointer_cache->entries = (rdpPointer**) malloc(sizeof(rdpPointer*) * pointer_cache->cacheSize); + ZeroMemory(pointer_cache->entries, sizeof(rdpPointer*) * pointer_cache->cacheSize); } return pointer_cache; diff --git a/libfreerdp/codec/mppc_dec.c b/libfreerdp/codec/mppc_dec.c index e02862526..3ef4aeb2d 100644 --- a/libfreerdp/codec/mppc_dec.c +++ b/libfreerdp/codec/mppc_dec.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include @@ -1421,8 +1423,12 @@ struct rdp_mppc_dec* mppc_dec_new(void) return NULL; } - ptr->history_buf = (BYTE *) xzalloc(RDP6_HISTORY_BUF_SIZE); - ptr->offset_cache = (UINT16 *) xzalloc(RDP6_OFFSET_CACHE_SIZE); + ptr->history_buf = (BYTE*) malloc(RDP6_HISTORY_BUF_SIZE); + ZeroMemory(ptr->history_buf, RDP6_HISTORY_BUF_SIZE); + + ptr->offset_cache = (UINT16*) malloc(RDP6_OFFSET_CACHE_SIZE); + ZeroMemory(ptr->offset_cache, RDP6_OFFSET_CACHE_SIZE); + if (!ptr->history_buf) { printf("mppc_new(): system out of memory\n"); diff --git a/libfreerdp/codec/mppc_enc.c b/libfreerdp/codec/mppc_enc.c index 8e6238afc..91a748227 100644 --- a/libfreerdp/codec/mppc_enc.c +++ b/libfreerdp/codec/mppc_enc.c @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -447,22 +449,31 @@ struct rdp_mppc_enc* mppc_enc_new(int protocol_type) free(enc); return NULL; } + enc->first_pkt = 1; - enc->historyBuffer = (char*) xzalloc(enc->buf_len); + enc->historyBuffer = (char*) malloc(enc->buf_len); + ZeroMemory(enc->historyBuffer, enc->buf_len); + if (enc->historyBuffer == NULL) { free(enc); return NULL; } - enc->outputBufferPlus = (char*) xzalloc(enc->buf_len + 64); + + enc->outputBufferPlus = (char*) malloc(enc->buf_len + 64); + ZeroMemory(enc->outputBufferPlus, enc->buf_len + 64); + if (enc->outputBufferPlus == NULL) { free(enc->historyBuffer); free(enc); return NULL; } + enc->outputBuffer = enc->outputBufferPlus + 64; - enc->hash_table = (UINT16*) xzalloc(enc->buf_len * 2); + enc->hash_table = (UINT16*) malloc(enc->buf_len * 2); + ZeroMemory(enc->hash_table, enc->buf_len * 2); + if (enc->hash_table == NULL) { free(enc->historyBuffer); @@ -470,6 +481,7 @@ struct rdp_mppc_enc* mppc_enc_new(int protocol_type) free(enc); return NULL; } + return enc; } diff --git a/libfreerdp/codec/nsc.c b/libfreerdp/codec/nsc.c index c76e2a20a..777d296ba 100644 --- a/libfreerdp/codec/nsc.c +++ b/libfreerdp/codec/nsc.c @@ -25,10 +25,13 @@ #include #include #include + #ifdef HAVE_STDINT_H #include #endif +#include + #include #include @@ -194,7 +197,8 @@ static void nsc_context_initialize(NSC_CONTEXT* context, STREAM* s) length = context->width * context->height * 4; if (context->bmpdata == NULL) { - context->bmpdata = xzalloc(length + 16); + context->bmpdata = malloc(length + 16); + ZeroMemory(context->bmpdata, length + 16); context->bmpdata_length = length; } else if (length > context->bmpdata_length) diff --git a/libfreerdp/codec/rfx_pool.c b/libfreerdp/codec/rfx_pool.c index 7032a2593..b7d630ccf 100644 --- a/libfreerdp/codec/rfx_pool.c +++ b/libfreerdp/codec/rfx_pool.c @@ -25,7 +25,7 @@ #include #include -#include +#include #include "rfx_pool.h" @@ -33,10 +33,12 @@ RFX_POOL* rfx_pool_new() { RFX_POOL* pool; - pool = xnew(RFX_POOL); + pool = (RFX_POOL*) malloc(sizeof(RFX_POOL)); + ZeroMemory(pool, sizeof(RFX_POOL)); pool->size = 64; - pool->tiles = (RFX_TILE**) xzalloc(sizeof(RFX_TILE*) * pool->size); + pool->tiles = (RFX_TILE**) malloc(sizeof(RFX_TILE*) * pool->size); + ZeroMemory(pool->tiles, sizeof(RFX_TILE*) * pool->size); return pool; } @@ -80,7 +82,9 @@ RFX_TILE* rfx_pool_get_tile(RFX_POOL* pool) if (pool->count < 1) { - tile = xnew(RFX_TILE); + tile = (RFX_TILE*) malloc(sizeof(RFX_TILE)); + ZeroMemory(tile, sizeof(RFX_TILE)); + tile->data = (BYTE*) malloc(4096 * 4); /* 64x64 * 4 */ } else diff --git a/server/X11/xf_event.c b/server/X11/xf_event.c index 5086a5ca3..4ef8554d0 100644 --- a/server/X11/xf_event.c +++ b/server/X11/xf_event.c @@ -28,7 +28,7 @@ #include #include -#include +#include #include "xf_event.h" @@ -146,7 +146,10 @@ xfEvent* xf_event_pop(xfEventQueue* event_queue) xfEventRegion* xf_event_region_new(int x, int y, int width, int height) { - xfEventRegion* event_region = xnew(xfEventRegion); + xfEventRegion* event_region; + + event_region = (xfEventRegion*) malloc(sizeof(xfEventRegion)); + ZeroMemory(event_region, sizeof(xfEventRegion)); if (event_region != NULL) { @@ -166,7 +169,9 @@ void xf_event_region_free(xfEventRegion* event_region) xfEvent* xf_event_new(int type) { - xfEvent* event = xnew(xfEvent); + xfEvent* event; + event = (xfEvent*) malloc(sizeof(xfEvent)); + ZeroMemory(event, sizeof(xfEvent)); event->type = type; return event; } @@ -178,7 +183,10 @@ void xf_event_free(xfEvent* event) xfEventQueue* xf_event_queue_new() { - xfEventQueue* event_queue = xnew(xfEventQueue); + xfEventQueue* event_queue; + + event_queue = (xfEventQueue*) malloc(sizeof(xfEventQueue)); + ZeroMemory(event_queue, sizeof(xfEventQueue)); if (event_queue != NULL) { @@ -187,7 +195,8 @@ xfEventQueue* xf_event_queue_new() event_queue->size = 16; event_queue->count = 0; - event_queue->events = (xfEvent**) xzalloc(sizeof(xfEvent*) * event_queue->size); + event_queue->events = (xfEvent**) malloc(sizeof(xfEvent*) * event_queue->size); + ZeroMemory(event_queue->events, sizeof(xfEvent*) * event_queue->size); if (pipe(event_queue->pipe_fd) < 0) printf("xf_event_queue_new: pipe failed\n");