[core] Coverity fixes
* [core] Coverity CID 1468218 (Resource leak) * [core] Coverity CID 1468214 (Resource leak) * [core] Coverity CID 1294472 (Resource leak) * [core] Coverity CID 1294470 (Resource leak) * [core] Coverity CID 1500361 (Resource leak) * [core] Coverity CID 1500308 (Resource leak) * [core] Coverity CID 1500278 (Resource leak) --------- Co-authored-by: Andrey Volk <andywolk@gmail.com>
This commit is contained in:
parent
04dd67da00
commit
49c1c35982
|
@ -448,7 +448,7 @@ SWITCH_DECLARE(switch_status_t) switch_img_to_raw(switch_image_t *src, void *des
|
||||||
* \param[in] width The raw data width
|
* \param[in] width The raw data width
|
||||||
* \param[in] height The raw data height
|
* \param[in] height The raw data height
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t *dest, void *src, switch_img_fmt_t fmt, int width, int height);
|
SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t** destP, void *src, switch_img_fmt_t fmt, int width, int height);
|
||||||
SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, switch_bool_t full, const char *text);
|
SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, switch_bool_t full, const char *text);
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_image_t *) switch_img_read_file(const char* file_name);
|
SWITCH_DECLARE(switch_image_t *) switch_img_read_file(const char* file_name);
|
||||||
|
|
|
@ -854,7 +854,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->rawImage && (context->debug || !context->overlay_count)) {
|
if (context->rawImage && (context->debug || !context->overlay_count)) {
|
||||||
switch_img_from_raw(frame->img, (uint8_t *)context->rawImage->imageData, SWITCH_IMG_FMT_RGB24, context->rawImage->width, context->rawImage->height);
|
switch_img_from_raw(&frame->img, (uint8_t *)context->rawImage->imageData, SWITCH_IMG_FMT_RGB24, context->rawImage->width, context->rawImage->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
int abs = 0;
|
int abs = 0;
|
||||||
|
|
|
@ -645,7 +645,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch_img_from_raw(frame->img, patch_data, SWITCH_IMG_FMT_ARGB, frame->img->d_w, frame->img->d_h);
|
switch_img_from_raw(&frame->img, patch_data, SWITCH_IMG_FMT_ARGB, frame->img->d_w, frame->img->d_h);
|
||||||
|
|
||||||
switch_img_free(&img);
|
switch_img_free(&img);
|
||||||
|
|
||||||
|
|
|
@ -387,7 +387,7 @@ static switch_status_t read_page(pdf_file_context_t *context)
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_img_from_raw(context->img, storage, SWITCH_IMG_FMT_BGR24, w, h);
|
switch_img_from_raw(&context->img, storage, SWITCH_IMG_FMT_BGR24, w, h);
|
||||||
free(storage);
|
free(storage);
|
||||||
} else {
|
} else {
|
||||||
switch_image_t *img = switch_img_alloc(NULL, SWITCH_IMG_FMT_ARGB, image->columns, image->rows, 0);
|
switch_image_t *img = switch_img_alloc(NULL, SWITCH_IMG_FMT_ARGB, image->columns, image->rows, 0);
|
||||||
|
|
|
@ -3181,6 +3181,8 @@ static int recover_callback(void *pArg, int argc, char **argv, char **columnName
|
||||||
|
|
||||||
if (!(ep = switch_loadable_module_get_endpoint_interface(argv[0]))) {
|
if (!(ep = switch_loadable_module_get_endpoint_interface(argv[0]))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "EP ERROR\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "EP ERROR\n");
|
||||||
|
switch_xml_free(xml);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3521,11 +3521,18 @@ SWITCH_DECLARE(switch_status_t) switch_img_to_raw(switch_image_t *src, void *des
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t *dest, void *src, switch_img_fmt_t fmt, int width, int height)
|
SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t **destP, void *src, switch_img_fmt_t fmt, int width, int height)
|
||||||
{
|
{
|
||||||
#ifdef SWITCH_HAVE_YUV
|
#ifdef SWITCH_HAVE_YUV
|
||||||
uint32_t fourcc;
|
uint32_t fourcc;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
switch_image_t *dest = NULL;
|
||||||
|
|
||||||
|
if (!destP) {
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
dest = *destP;
|
||||||
|
|
||||||
fourcc = switch_img_fmt2fourcc(fmt);
|
fourcc = switch_img_fmt2fourcc(fmt);
|
||||||
|
|
||||||
|
@ -3574,6 +3581,8 @@ SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t *dest, void *
|
||||||
0, fourcc);
|
0, fourcc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*destP = dest;
|
||||||
|
|
||||||
return ret == 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
|
return ret == 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
|
||||||
#else
|
#else
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
|
@ -3586,10 +3595,12 @@ SWITCH_DECLARE(switch_status_t) switch_img_scale(switch_image_t *src, switch_ima
|
||||||
switch_image_t *dest = NULL;
|
switch_image_t *dest = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (destP) {
|
if (!destP) {
|
||||||
dest = *destP;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dest = *destP;
|
||||||
|
|
||||||
switch_assert(width > 0);
|
switch_assert(width > 0);
|
||||||
switch_assert(height > 0);
|
switch_assert(height > 0);
|
||||||
|
|
||||||
|
@ -3615,15 +3626,13 @@ SWITCH_DECLARE(switch_status_t) switch_img_scale(switch_image_t *src, switch_ima
|
||||||
kFilterBox);
|
kFilterBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*destP = dest;
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scaling Error: ret: %d\n", ret);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scaling Error: ret: %d\n", ret);
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destP) {
|
|
||||||
*destP = dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
#else
|
#else
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
|
@ -3637,10 +3646,12 @@ SWITCH_DECLARE(switch_status_t) switch_img_mirror(switch_image_t *src, switch_im
|
||||||
switch_image_t *dest = NULL;
|
switch_image_t *dest = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (destP) {
|
if (!destP) {
|
||||||
dest = *destP;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dest = *destP;
|
||||||
|
|
||||||
if (dest && src->fmt != dest->fmt) switch_img_free(&dest);
|
if (dest && src->fmt != dest->fmt) switch_img_free(&dest);
|
||||||
|
|
||||||
if (!dest) dest = switch_img_alloc(NULL, src->fmt, src->d_w, src->d_h, 1);
|
if (!dest) dest = switch_img_alloc(NULL, src->fmt, src->d_w, src->d_h, 1);
|
||||||
|
@ -3660,15 +3671,13 @@ SWITCH_DECLARE(switch_status_t) switch_img_mirror(switch_image_t *src, switch_im
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*destP = dest;
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Mirror Error: ret: %d\n", ret);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Mirror Error: ret: %d\n", ret);
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destP) {
|
|
||||||
*destP = dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
#else
|
#else
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
|
|
|
@ -1909,6 +1909,8 @@ SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const ch
|
||||||
data = (char *) malloc(2048);
|
data = (char *) malloc(2048);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
switch_xml_free(xml);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ret = vsnprintf(data, 2048, fmt, ap);
|
ret = vsnprintf(data, 2048, fmt, ap);
|
||||||
|
@ -1918,6 +1920,8 @@ SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const ch
|
||||||
#ifndef HAVE_VASPRINTF
|
#ifndef HAVE_VASPRINTF
|
||||||
free(data);
|
free(data);
|
||||||
#endif
|
#endif
|
||||||
|
switch_xml_free(xml);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1638,11 +1638,25 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_file_simple(const char *file)
|
||||||
|
|
||||||
if ((fd = open(file, O_RDONLY, 0)) > -1) {
|
if ((fd = open(file, O_RDONLY, 0)) > -1) {
|
||||||
fstat(fd, &st);
|
fstat(fd, &st);
|
||||||
if (!st.st_size) goto error;
|
if (!st.st_size) {
|
||||||
|
close(fd);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
m = switch_must_malloc(st.st_size);
|
m = switch_must_malloc(st.st_size);
|
||||||
|
|
||||||
if (!(0<(l = read(fd, m, st.st_size)))) goto error;
|
if (!(0 < (l = read(fd, m, st.st_size)))) {
|
||||||
if (!(root = (switch_xml_root_t) switch_xml_parse_str((char *) m, l))) goto error;
|
free(m);
|
||||||
|
close(fd);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(root = (switch_xml_root_t)switch_xml_parse_str((char*)m, l))) {
|
||||||
|
free(m);
|
||||||
|
close(fd);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
root->dynamic = 1;
|
root->dynamic = 1;
|
||||||
close(fd);
|
close(fd);
|
||||||
return &root->xml;
|
return &root->xml;
|
||||||
|
|
Loading…
Reference in New Issue