Log Level for Mask and Memory Leak

Revise the log level to warning when the user has specified a pgm mask file that is
different than the size of the image from the camera.

Free the memory associated with mask image to close memory leak.
This commit is contained in:
MrDave
2016-09-23 20:48:04 -06:00
parent 787fad43fe
commit 45f18a4dfe
2 changed files with 5 additions and 1 deletions

View File

@@ -1018,6 +1018,9 @@ static void motion_cleanup(struct context *cnt)
free(cnt->imgs.smartmask_buffer);
cnt->imgs.smartmask_buffer = NULL;
if (cnt->imgs.mask) free(cnt->imgs.mask);
cnt->imgs.mask = NULL;
free(cnt->imgs.common_buffer);
cnt->imgs.common_buffer = NULL;

View File

@@ -1018,7 +1018,8 @@ unsigned char *get_pgm(FILE *picture, int width, int height)
/* Resize mask if required */
if (mask_width != width || mask_height != height) {
MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, "%s: Mask needs resizing from %dx%d to %dx%d",
MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: The mask file specified is not the same size as image from camera.");
MOTION_LOG(WRN, TYPE_ALL, NO_ERRNO, "%s: Attempting to resize mask image from %dx%d to %dx%d",
mask_width, mask_height, width, height);
resized_image = mymalloc(width * height);