libfreerdp-core: fix more memory leaks
This commit is contained in:
parent
b9c782fb21
commit
9e4d76648b
@ -52,7 +52,7 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS
|
||||
}
|
||||
else
|
||||
{
|
||||
STREAM* body = NULL;
|
||||
STREAM* body = stream_new(0);
|
||||
|
||||
for (i = 0; i < cb_event->num_formats; i++)
|
||||
{
|
||||
@ -80,9 +80,6 @@ void cliprdr_process_format_list_event(cliprdrPlugin* cliprdr, RDP_CB_FORMAT_LIS
|
||||
if (!cliprdr->use_long_format_names)
|
||||
name_length = 32;
|
||||
|
||||
if (body == NULL)
|
||||
body = stream_new(4 + name_length);
|
||||
else
|
||||
stream_extend(body, stream_get_size(body) + 4 + name_length);
|
||||
|
||||
stream_write_uint32(body, cb_event->formats[i]);
|
||||
@ -170,15 +167,19 @@ void cliprdr_process_long_format_names(cliprdrPlugin* cliprdr, STREAM* s, uint32
|
||||
if (cliprdr->num_format_names >= allocated_formats)
|
||||
{
|
||||
allocated_formats *= 2;
|
||||
cliprdr->format_names = (CLIPRDR_FORMAT_NAME*) xrealloc(cliprdr->format_names, sizeof(CLIPRDR_FORMAT_NAME) * allocated_formats);
|
||||
cliprdr->format_names = (CLIPRDR_FORMAT_NAME*) xrealloc(cliprdr->format_names,
|
||||
sizeof(CLIPRDR_FORMAT_NAME) * allocated_formats);
|
||||
}
|
||||
|
||||
format_name = &cliprdr->format_names[cliprdr->num_format_names++];
|
||||
stream_read_uint32(s, format_name->id);
|
||||
|
||||
for (p = stream_get_tail(s), name_len = 0; p+1 < end_mark; p += 2, name_len += 2)
|
||||
format_name->name = NULL;
|
||||
format_name->length = 0;
|
||||
|
||||
for (p = stream_get_tail(s), name_len = 0; p + 1 < end_mark; p += 2, name_len += 2)
|
||||
{
|
||||
if (*((unsigned short*)p) == 0)
|
||||
if (*((unsigned short*) p) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@ -266,10 +267,21 @@ void cliprdr_process_format_list(cliprdrPlugin* cliprdr, STREAM* s, uint32 dataL
|
||||
|
||||
if (supported)
|
||||
cb_event->formats[cb_event->num_formats++] = format;
|
||||
|
||||
if (format_name->length > 0)
|
||||
xfree(format_name->name);
|
||||
}
|
||||
|
||||
if (cliprdr->format_names != NULL)
|
||||
{
|
||||
for (i = 0; i < cliprdr->num_format_names; i++)
|
||||
{
|
||||
format_name = &cliprdr->format_names[i];
|
||||
|
||||
if (format_name->length > 0)
|
||||
xfree(format_name->name);
|
||||
}
|
||||
|
||||
xfree(cliprdr->format_names);
|
||||
cliprdr->format_names = NULL;
|
||||
}
|
||||
|
@ -645,8 +645,6 @@ boolean xf_post_connect(freerdp* instance)
|
||||
|
||||
xfi->hdc = gdi_CreateDC(xfi->clrconv, xfi->bpp);
|
||||
|
||||
xfi->primary_buffer = (uint8*) xzalloc(xfi->width * xfi->height * xfi->bpp);
|
||||
|
||||
if (instance->settings->rfx_codec)
|
||||
{
|
||||
rfx_context = (void*) rfx_context_new();
|
||||
@ -866,6 +864,9 @@ void xf_window_free(xfInfo* xfi)
|
||||
XFreeGC(xfi->display, xfi->gc);
|
||||
xfi->gc = 0;
|
||||
|
||||
XFreeGC(xfi->display, xfi->gc_mono);
|
||||
xfi->gc_mono = 0;
|
||||
|
||||
if (xfi->window != NULL)
|
||||
{
|
||||
xf_DestroyWindow(xfi, xfi->window);
|
||||
@ -920,6 +921,7 @@ void xf_free(xfInfo* xfi)
|
||||
xfree(xfi->bmp_codec_none);
|
||||
|
||||
XCloseDisplay(xfi->display);
|
||||
|
||||
xfree(xfi);
|
||||
}
|
||||
|
||||
@ -1060,7 +1062,7 @@ void* thread_func(void* param)
|
||||
if (g_thread_count < 1)
|
||||
freerdp_sem_signal(g_sem);
|
||||
|
||||
return NULL;
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
static uint8 exit_code_from_disconnect_reason(uint32 reason)
|
||||
|
@ -86,6 +86,8 @@ void* brush_cache_get(rdpBrushCache* brush, uint32 index, uint32* bpp)
|
||||
|
||||
void brush_cache_put(rdpBrushCache* brush, uint32 index, void* entry, uint32 bpp)
|
||||
{
|
||||
void* prevEntry;
|
||||
|
||||
if (bpp == 1)
|
||||
{
|
||||
if (index > brush->maxMonoEntries)
|
||||
@ -94,6 +96,11 @@ void brush_cache_put(rdpBrushCache* brush, uint32 index, void* entry, uint32 bpp
|
||||
return;
|
||||
}
|
||||
|
||||
prevEntry = brush->monoEntries[index].entry;
|
||||
|
||||
if (prevEntry != NULL)
|
||||
xfree(prevEntry);
|
||||
|
||||
brush->monoEntries[index].bpp = bpp;
|
||||
brush->monoEntries[index].entry = entry;
|
||||
}
|
||||
@ -105,6 +112,11 @@ void brush_cache_put(rdpBrushCache* brush, uint32 index, void* entry, uint32 bpp
|
||||
return;
|
||||
}
|
||||
|
||||
prevEntry = brush->entries[index].entry;
|
||||
|
||||
if (prevEntry != NULL)
|
||||
xfree(prevEntry);
|
||||
|
||||
brush->entries[index].bpp = bpp;
|
||||
brush->entries[index].entry = entry;
|
||||
}
|
||||
|
@ -90,12 +90,19 @@ rdpPointer* pointer_cache_get(rdpPointerCache* pointer_cache, uint32 index)
|
||||
|
||||
void pointer_cache_put(rdpPointerCache* pointer_cache, uint32 index, rdpPointer* pointer)
|
||||
{
|
||||
rdpPointer* prevPointer;
|
||||
|
||||
if (index >= pointer_cache->cacheSize)
|
||||
{
|
||||
printf("invalid pointer index:%d\n", index);
|
||||
return;
|
||||
}
|
||||
|
||||
prevPointer = pointer_cache->entries[index];
|
||||
|
||||
if (prevPointer != NULL)
|
||||
Pointer_Free(pointer_cache->update->context, prevPointer);
|
||||
|
||||
pointer_cache->entries[index] = pointer;
|
||||
}
|
||||
|
||||
@ -121,7 +128,7 @@ rdpPointerCache* pointer_cache_new(rdpSettings* settings)
|
||||
pointer_cache->settings = settings;
|
||||
pointer_cache->cacheSize = settings->pointer_cache_size;
|
||||
pointer_cache->update = ((freerdp*) settings->instance)->update;
|
||||
pointer_cache->entries = xzalloc(sizeof(rdpPointer**) * pointer_cache->cacheSize);
|
||||
pointer_cache->entries = (rdpPointer**) xzalloc(sizeof(rdpPointer*) * pointer_cache->cacheSize);
|
||||
}
|
||||
|
||||
return pointer_cache;
|
||||
|
@ -130,7 +130,7 @@ void certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info)
|
||||
int exponent_length;
|
||||
|
||||
s = stream_new(0);
|
||||
s->p = s->data = cert->data;
|
||||
stream_attach(s, cert->data, cert->length);
|
||||
|
||||
ber_read_sequence_tag(s, &length); /* Certificate (SEQUENCE) */
|
||||
|
||||
@ -195,6 +195,9 @@ void certificate_read_x509_certificate(rdpCertBlob* cert, rdpCertInfo* info)
|
||||
stream_read(s, &info->exponent[4 - exponent_length], exponent_length);
|
||||
crypto_reverse(info->modulus.data, modulus_length);
|
||||
crypto_reverse(info->exponent, 4);
|
||||
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,16 +227,17 @@ void certificate_free_x509_certificate_chain(rdpX509CertChain* x509_cert_chain)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (x509_cert_chain == NULL)
|
||||
return;
|
||||
|
||||
if (x509_cert_chain != NULL)
|
||||
{
|
||||
for (i = 0; i < (int) x509_cert_chain->count; i++)
|
||||
{
|
||||
if (x509_cert_chain->array[i].data != NULL)
|
||||
xfree(x509_cert_chain->array[i].data);
|
||||
}
|
||||
|
||||
xfree(x509_cert_chain->array);
|
||||
xfree(x509_cert_chain);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean certificate_process_server_public_key(rdpCertificate* certificate, STREAM* s, uint32 length)
|
||||
|
@ -426,10 +426,11 @@ void credssp_encode_ts_credentials(rdpCredssp* credssp)
|
||||
s = stream_new(0);
|
||||
length = credssp_skip_ts_credentials(credssp);
|
||||
freerdp_blob_alloc(&credssp->ts_credentials, length);
|
||||
s->p = s->data = credssp->ts_credentials.data;
|
||||
s->size = length;
|
||||
stream_attach(s, credssp->ts_credentials.data, length);
|
||||
|
||||
credssp_write_ts_credentials(credssp, s);
|
||||
stream_detach(s);
|
||||
stream_free(s);
|
||||
}
|
||||
|
||||
int credssp_skip_nego_token(int length)
|
||||
|
@ -65,7 +65,12 @@ void stream_extend(STREAM* stream, int request_size)
|
||||
original_size = stream->size;
|
||||
increased_size = (request_size > original_size ? request_size : original_size);
|
||||
stream->size += increased_size;
|
||||
|
||||
if (original_size == 0)
|
||||
stream->data = (uint8*) xmalloc(stream->size);
|
||||
else
|
||||
stream->data = (uint8*) xrealloc(stream->data, stream->size);
|
||||
|
||||
memset(stream->data + original_size, 0, increased_size);
|
||||
stream_set_pos(stream, pos);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user