From 45f18a4dfe8166dcf583f440d506a44fbfcc7a2c Mon Sep 17 00:00:00 2001 From: MrDave Date: Fri, 23 Sep 2016 20:48:04 -0600 Subject: [PATCH] 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. --- motion.c | 3 +++ picture.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/motion.c b/motion.c index 1bf0e267..9993b9a1 100644 --- a/motion.c +++ b/motion.c @@ -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; diff --git a/picture.c b/picture.c index 7ca4d7e2..79c52071 100644 --- a/picture.c +++ b/picture.c @@ -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);