diff --git a/src/alg_sec.cpp b/src/alg_sec.cpp index a9a21456..54682228 100644 --- a/src/alg_sec.cpp +++ b/src/alg_sec.cpp @@ -391,8 +391,8 @@ static void algsec_params_deinit(ctx_algsec_model &algmdl) util_parms_free(algmdl.algsec_params); if (algmdl.algsec_params != NULL) { free(algmdl.algsec_params); + algmdl.algsec_params = NULL; } - algmdl.algsec_params = NULL; } } @@ -564,8 +564,8 @@ void algsec_deinit(ctx_cam *cam) if (cam->algsec->image_norm != NULL){ if (cam->algsec->image_norm != NULL) { free(cam->algsec->image_norm); + cam->algsec->image_norm = NULL; } - cam->algsec->image_norm = NULL; } if (waitcnt == 1000){ diff --git a/src/conf.cpp b/src/conf.cpp index 8c1abaaf..537ccb5d 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -4109,8 +4109,8 @@ void conf_deinit(struct ctx_motapp *motapp) if (motapp->cam_list != NULL) { free(motapp->cam_list); + motapp->cam_list = NULL; } - motapp->cam_list = NULL; } diff --git a/src/dbse.cpp b/src/dbse.cpp index 422cc2b8..7a1ac6d3 100644 --- a/src/dbse.cpp +++ b/src/dbse.cpp @@ -84,8 +84,8 @@ void dbse_global_deinit(struct ctx_motapp *motapp) while (motapp->cam_list[indx] != NULL) { if (motapp->cam_list[indx]->dbse != NULL) { free(motapp->cam_list[indx]->dbse); + motapp->cam_list[indx]->dbse = NULL; } - motapp->cam_list[indx]->dbse = NULL; indx++; } diff --git a/src/event.cpp b/src/event.cpp index 1d30a9d4..c94c005d 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -605,8 +605,8 @@ static void event_movie_start(struct ctx_cam *cam, motion_event evnt ,_("Error opening ctx_cam for movie output.")); if (cam->movie_norm != NULL) { free(cam->movie_norm); + cam->movie_norm = NULL; } - cam->movie_norm = NULL; return; } event(cam, EVENT_FILECREATE, NULL, cam->movie_norm->filename, (void *)FTYPE_MOVIE, ts1); @@ -620,8 +620,8 @@ static void event_movie_start(struct ctx_cam *cam, motion_event evnt ,_("Error creating motion file [%s]"), cam->movie_motion->filename); if (cam->movie_motion != NULL) { free(cam->movie_motion); + cam->movie_motion = NULL; } - cam->movie_motion = NULL; return; } } @@ -661,8 +661,8 @@ static void event_movie_end(struct ctx_cam *cam, motion_event evnt movie_close(cam->movie_norm); if (cam->movie_norm != NULL) { free(cam->movie_norm); + cam->movie_norm = NULL; } - cam->movie_norm = NULL; if ((cam->conf->movie_retain == "secondary") && (cam->algsec_inuse)) { if (cam->algsec->isdetected == false) { @@ -687,9 +687,9 @@ static void event_movie_end(struct ctx_cam *cam, motion_event evnt movie_close(cam->movie_motion); if (cam->movie_motion != NULL) { free(cam->movie_motion); + cam->movie_motion = NULL; } - cam->movie_motion = NULL; if ((cam->conf->movie_retain == "secondary") && (cam->algsec_inuse)) { if (cam->algsec->isdetected == false) { retcd = remove(cam->motionfilename); @@ -728,8 +728,8 @@ static void event_tlapse_start(struct ctx_cam *cam, motion_event evnt ,_("Error creating timelapse file [%s]"), cam->movie_timelapse->filename); if (cam->movie_timelapse != NULL) { free(cam->movie_timelapse); + cam->movie_timelapse = NULL; } - cam->movie_timelapse = NULL; return; } event(cam, EVENT_FILECREATE, NULL, cam->movie_timelapse->filename @@ -757,8 +757,8 @@ static void event_tlapse_end(struct ctx_cam *cam, motion_event evnt movie_close(cam->movie_timelapse); if (cam->movie_timelapse != NULL) { free(cam->movie_timelapse); + cam->movie_timelapse = NULL; } - cam->movie_timelapse = NULL; event(cam, EVENT_FILECLOSE, NULL, cam->timelapsefilename, (void *)FTYPE_MOVIE_TIMELAPSE, ts1); dbse_exec(cam, cam->timelapsefilename, FTYPE_MOVIE_TIMELAPSE, ts1, "movie_end"); } diff --git a/src/exif.cpp b/src/exif.cpp index ee65c86b..0e2afa6a 100644 --- a/src/exif.cpp +++ b/src/exif.cpp @@ -347,8 +347,8 @@ unsigned exif_prepare(unsigned char **exif, const struct ctx_cam *cam, if (description != NULL) { free(description); + description = NULL; } - description = NULL; *exif = marker; return marker_len; diff --git a/src/mmalcam.cpp b/src/mmalcam.cpp index 846e95e4..4acc8fdb 100644 --- a/src/mmalcam.cpp +++ b/src/mmalcam.cpp @@ -384,13 +384,13 @@ void mmalcam_cleanup(struct ctx_mmalcam *mmalcam) if (mmalcam->camera_parameters != NULL) { free(mmalcam->camera_parameters); + mmalcam->camera_parameters = NULL; } - mmalcam->camera_parameters = NULL; if (mmalcam != NULL) { free(mmalcam); + mmalcam = NULL; } - mmalcam = NULL; } #else (void)mmalcam; diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp index bc779512..318f081d 100644 --- a/src/motion_loop.cpp +++ b/src/motion_loop.cpp @@ -76,8 +76,8 @@ static void mlp_ring_resize(struct ctx_cam *cam, int new_size) if (cam->imgs.image_ring != NULL) { free(cam->imgs.image_ring); + cam->imgs.image_ring = NULL; } - cam->imgs.image_ring = NULL; cam->imgs.image_ring = tmp; cam->current_image = NULL; @@ -101,21 +101,25 @@ static void mlp_ring_destroy(struct ctx_cam *cam) for (i = 0; i < cam->imgs.ring_size; i++) { if (cam->imgs.image_ring[i].image_norm != NULL) { free(cam->imgs.image_ring[i].image_norm); + cam->imgs.image_ring[i].image_norm = NULL; } - cam->imgs.image_ring[i].image_norm = NULL; if (cam->imgs.image_ring[i].image_high != NULL) { free(cam->imgs.image_ring[i].image_high); + cam->imgs.image_ring[i].image_high = NULL; } - cam->imgs.image_ring[i].image_high = NULL; + } if (cam->imgs.image_ring != NULL) { free(cam->imgs.image_ring); + cam->imgs.image_ring = NULL; + } + + if (cam->current_image != NULL) { + free(cam->current_image); + cam->current_image = NULL; } - cam->imgs.image_ring = NULL; - cam->imgs.image_ring = NULL; - cam->current_image = NULL; cam->imgs.ring_size = 0; } @@ -778,98 +782,98 @@ void mlp_cleanup(struct ctx_cam *cam) if (cam->imgs.image_motion.image_norm != NULL) { free(cam->imgs.image_motion.image_norm); + cam->imgs.image_motion.image_norm = NULL; } - cam->imgs.image_motion.image_norm = NULL; if (cam->imgs.ref != NULL) { free(cam->imgs.ref); + cam->imgs.ref = NULL; } - cam->imgs.ref = NULL; if (cam->imgs.ref_dyn != NULL) { free(cam->imgs.ref_dyn); + cam->imgs.ref_dyn = NULL; } - cam->imgs.ref_dyn = NULL; if (cam->imgs.image_virgin != NULL) { free(cam->imgs.image_virgin); + cam->imgs.image_virgin = NULL; } - cam->imgs.image_virgin = NULL; if (cam->imgs.image_vprvcy != NULL) { free(cam->imgs.image_vprvcy); + cam->imgs.image_vprvcy = NULL; } - cam->imgs.image_vprvcy = NULL; if (cam->imgs.labels != NULL) { free(cam->imgs.labels); + cam->imgs.labels = NULL; } - cam->imgs.labels = NULL; if (cam->imgs.labelsize != NULL) { free(cam->imgs.labelsize); + cam->imgs.labelsize = NULL; } - cam->imgs.labelsize = NULL; if (cam->imgs.smartmask != NULL) { free(cam->imgs.smartmask); + cam->imgs.smartmask = NULL; } - cam->imgs.smartmask = NULL; if (cam->imgs.smartmask_final != NULL) { free(cam->imgs.smartmask_final); + cam->imgs.smartmask_final = NULL; } - cam->imgs.smartmask_final = NULL; if (cam->imgs.smartmask_buffer != NULL) { free(cam->imgs.smartmask_buffer); + cam->imgs.smartmask_buffer = NULL; } - cam->imgs.smartmask_buffer = NULL; if (cam->imgs.mask != NULL) { free(cam->imgs.mask); + cam->imgs.mask = NULL; } - cam->imgs.mask = NULL; if (cam->imgs.mask_privacy != NULL) { free(cam->imgs.mask_privacy); + cam->imgs.mask_privacy = NULL; } - cam->imgs.mask_privacy = NULL; if (cam->imgs.mask_privacy_uv != NULL) { free(cam->imgs.mask_privacy_uv); + cam->imgs.mask_privacy_uv = NULL; } - cam->imgs.mask_privacy_uv = NULL; if (cam->imgs.mask_privacy_high != NULL) { free(cam->imgs.mask_privacy_high); + cam->imgs.mask_privacy_high = NULL; } - cam->imgs.mask_privacy_high = NULL; if (cam->imgs.mask_privacy_high_uv != NULL) { free(cam->imgs.mask_privacy_high_uv); + cam->imgs.mask_privacy_high_uv = NULL; } - cam->imgs.mask_privacy_high_uv = NULL; if (cam->imgs.common_buffer != NULL) { free(cam->imgs.common_buffer); + cam->imgs.common_buffer = NULL; } - cam->imgs.common_buffer = NULL; if (cam->imgs.image_secondary != NULL) { free(cam->imgs.image_secondary); + cam->imgs.image_secondary = NULL; } - cam->imgs.image_secondary = NULL; if (cam->imgs.image_preview.image_norm != NULL) { free(cam->imgs.image_preview.image_norm); + cam->imgs.image_preview.image_norm = NULL; } - cam->imgs.image_preview.image_norm = NULL; if (cam->imgs.image_preview.image_high != NULL) { free(cam->imgs.image_preview.image_high); + cam->imgs.image_preview.image_high = NULL; } - cam->imgs.image_preview.image_high = NULL; mlp_ring_destroy(cam); /* Cleanup the precapture ring buffer */ diff --git a/src/motionplus.cpp b/src/motionplus.cpp index acf274a7..71d8678f 100644 --- a/src/motionplus.cpp +++ b/src/motionplus.cpp @@ -696,8 +696,8 @@ static void motion_cam_delete(struct ctx_motapp *motapp) if (motapp->cam_list[motapp->cam_delete]->dbse != NULL) { free(motapp->cam_list[motapp->cam_delete]->dbse); + motapp->cam_list[motapp->cam_delete]->dbse = NULL; } - motapp->cam_list[motapp->cam_delete]->dbse = NULL; dbse_motpls_deinit(motapp->cam_list[motapp->cam_delete]); @@ -724,6 +724,7 @@ static void motion_cam_delete(struct ctx_motapp *motapp) pthread_mutex_lock(&motapp->mutex_camlst); if (motapp->cam_list != NULL) { free(motapp->cam_list); + motapp->cam_list = NULL; } motapp->cam_list = tmp; pthread_mutex_unlock(&motapp->mutex_camlst); diff --git a/src/movie.cpp b/src/movie.cpp index 5c821dd0..c262d3b5 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -153,8 +153,8 @@ static int movie_get_oformat(struct ctx_movie *movie) movie_free_context(movie); if (container_name != NULL) { free(container_name); + container_name = NULL; } - container_name = NULL; return -1; } @@ -172,14 +172,14 @@ static int movie_get_oformat(struct ctx_movie *movie) movie_free_context(movie); if (container_name != NULL) { free(container_name); + container_name = NULL; } - container_name = NULL; return -1; } if (container_name != NULL) { free(container_name); + container_name = NULL; } - container_name = NULL; return 0; } @@ -238,8 +238,8 @@ static int movie_get_oformat(struct ctx_movie *movie) movie_free_context(movie); if (container_name != NULL) { free(container_name); + container_name = NULL; } - container_name = NULL; return -1; } @@ -249,8 +249,8 @@ static int movie_get_oformat(struct ctx_movie *movie) movie_free_context(movie); if (container_name != NULL) { free(container_name); + container_name = NULL; } - container_name = NULL; return -1; } @@ -259,15 +259,15 @@ static int movie_get_oformat(struct ctx_movie *movie) movie_free_context(movie); if (container_name != NULL) { free(container_name); + container_name = NULL; } - container_name = NULL; return -1; } if (container_name != NULL) { free(container_name); + container_name = NULL; } - container_name = NULL; return 0; } @@ -367,8 +367,8 @@ static int movie_encode_video(struct ctx_movie *movie) if (video_outbuf != NULL) { free(video_outbuf); + video_outbuf = NULL; } - video_outbuf = NULL; /* This kills compiler warnings. Nal setting is only for recent movie versions*/ if (movie->preferred_codec == USER_CODEC_V4L2M2M) { diff --git a/src/netcam.cpp b/src/netcam.cpp index 97a62247..4e58aebe 100644 --- a/src/netcam.cpp +++ b/src/netcam.cpp @@ -1886,31 +1886,31 @@ static void netcam_shutdown(struct ctx_netcam *netcam) if (netcam->path != NULL) { free(netcam->path); + netcam->path = NULL; } - netcam->path = NULL; if (netcam->img_latest != NULL) { free(netcam->img_latest->ptr); free(netcam->img_latest); + netcam->img_latest = NULL; } - netcam->img_latest = NULL; if (netcam->img_recv != NULL) { free(netcam->img_recv->ptr); free(netcam->img_recv); + netcam->img_recv = NULL; } - netcam->img_recv = NULL; if (netcam->decoder_nm != NULL) { free(netcam->decoder_nm); + netcam->decoder_nm = NULL; } - netcam->decoder_nm = NULL; util_parms_free(netcam->params); if (netcam->params != NULL) { free(netcam->params); + netcam->params = NULL; } - netcam->params = NULL; } } @@ -2304,8 +2304,11 @@ void netcam_cleanup(struct ctx_cam *cam, bool init_retry_flag) pthread_mutex_destroy(&netcam->mutex_pktarray); pthread_mutex_destroy(&netcam->mutex_transfer); - free(netcam); - netcam = NULL; + if (netcam != NULL) { + free(netcam); + netcam = NULL; + } + if (indx_cam == 1) { MOTION_LOG(NTC, TYPE_NETCAM, NO_ERRNO ,_("Norm: Shut down complete.")); diff --git a/src/rotate.cpp b/src/rotate.cpp index dbfffa54..a67e86ba 100644 --- a/src/rotate.cpp +++ b/src/rotate.cpp @@ -279,12 +279,14 @@ void rotate_deinit(struct ctx_cam *cam) return; } - if (cam->rotate_data->buffer_norm) { + if (cam->rotate_data->buffer_norm != NULL) { free(cam->rotate_data->buffer_norm); + cam->rotate_data->buffer_norm = NULL; } - if (cam->rotate_data->buffer_high) { + if (cam->rotate_data->buffer_high != NULL) { free(cam->rotate_data->buffer_high); + cam->rotate_data->buffer_high = NULL; } if (cam->rotate_data != NULL) { diff --git a/src/video_v4l2.cpp b/src/video_v4l2.cpp index e02e67da..bca57d9e 100644 --- a/src/video_v4l2.cpp +++ b/src/video_v4l2.cpp @@ -557,8 +557,8 @@ static int v4l2_set_palette(ctx_v4l2cam *v4l2cam) if (retcd >= 0) { if (palette_array != NULL) { free(palette_array); + palette_array = NULL; } - palette_array = NULL; return 0; } MOTION_LOG(NTC, TYPE_VIDEO, NO_ERRNO @@ -604,8 +604,8 @@ static int v4l2_set_palette(ctx_v4l2cam *v4l2cam) ,palette_array[indx_palette].fourcc); if (palette_array != NULL) { free(palette_array); + palette_array = NULL; } - palette_array = NULL; return 0; } MOTION_LOG(ERR, TYPE_VIDEO, NO_ERRNO @@ -617,8 +617,8 @@ static int v4l2_set_palette(ctx_v4l2cam *v4l2cam) ,_("Unable to find a compatible palette format.")); if (palette_array != NULL) { free(palette_array); + palette_array = NULL; } - palette_array = NULL; return -1; @@ -679,8 +679,8 @@ static int v4l2_set_mmap(ctx_v4l2cam *v4l2cam) ,buffer_index); if (v4l2cam->buffers != NULL) { free(v4l2cam->buffers); + v4l2cam->buffers = NULL; } - v4l2cam->buffers = NULL; return -1; } @@ -693,8 +693,8 @@ static int v4l2_set_mmap(ctx_v4l2cam *v4l2cam) ,_("Error mapping buffer %i mmap"), buffer_index); if (v4l2cam->buffers != NULL) { free(v4l2cam->buffers); + v4l2cam->buffers = NULL; } - v4l2cam->buffers = NULL; return -1; } @@ -1105,8 +1105,8 @@ static void v4l2_log_formats(ctx_v4l2cam *v4l2cam) if (palette_array != NULL) { free(palette_array); + palette_array = NULL; } - palette_array = NULL; return; } @@ -1170,26 +1170,26 @@ void v4l2_cleanup(ctx_cam *cam) } if (cam->v4l2cam->buffers != NULL) { free(cam->v4l2cam->buffers); + cam->v4l2cam->buffers = NULL; } - cam->v4l2cam->buffers = NULL; } if (cam->v4l2cam->devctrl_count != 0) { for (indx = 0; indx < cam->v4l2cam->devctrl_count; indx++){ if (cam->v4l2cam->devctrl_array[indx].ctrl_iddesc != NULL) { free(cam->v4l2cam->devctrl_array[indx].ctrl_iddesc); + cam->v4l2cam->devctrl_array[indx].ctrl_iddesc = NULL; } - cam->v4l2cam->devctrl_array[indx].ctrl_iddesc = NULL; if (cam->v4l2cam->devctrl_array[indx].ctrl_name != NULL) { free(cam->v4l2cam->devctrl_array[indx].ctrl_name); + cam->v4l2cam->devctrl_array[indx].ctrl_name = NULL; } - cam->v4l2cam->devctrl_array[indx].ctrl_name = NULL; } if (cam->v4l2cam->devctrl_array != NULL) { free(cam->v4l2cam->devctrl_array); + cam->v4l2cam->devctrl_array = NULL; } - cam->v4l2cam->devctrl_array = NULL; } cam->v4l2cam->devctrl_count=0; @@ -1202,8 +1202,8 @@ void v4l2_cleanup(ctx_cam *cam) if (cam->v4l2cam != NULL) { free(cam->v4l2cam); + cam->v4l2cam = NULL; } - cam->v4l2cam = NULL; cam->running_cam = false; #else @@ -1211,7 +1211,6 @@ void v4l2_cleanup(ctx_cam *cam) #endif // HAVE_V4L2 } - int v4l2_start(ctx_cam *cam) { #ifdef HAVE_V4L2 diff --git a/src/webu.cpp b/src/webu.cpp index d9a0c20f..2bd583a5 100644 --- a/src/webu.cpp +++ b/src/webu.cpp @@ -111,43 +111,43 @@ static void webu_context_free(struct ctx_webui *webui) if (webui->auth_user != NULL) { free(webui->auth_user); + webui->auth_user = NULL; } - webui->auth_user = NULL; if (webui->auth_pass != NULL) { free(webui->auth_pass); + webui->auth_pass = NULL; } - webui->auth_pass = NULL; if (webui->auth_opaque != NULL) { free(webui->auth_opaque); + webui->auth_opaque = NULL; } - webui->auth_opaque = NULL; if (webui->auth_realm != NULL) { free(webui->auth_realm); + webui->auth_realm = NULL; } - webui->auth_realm = NULL; if (webui->resp_image != NULL) { free(webui->resp_image); + webui->resp_image = NULL; } - webui->resp_image = NULL; for (indx = 0; indxpost_sz; indx++) { if (webui->post_info[indx].key_nm != NULL) { free(webui->post_info[indx].key_nm); + webui->post_info[indx].key_nm = NULL; } - webui->post_info[indx].key_nm = NULL; if (webui->post_info[indx].key_val != NULL) { free(webui->post_info[indx].key_val); + webui->post_info[indx].key_val = NULL; } - webui->post_info[indx].key_val = NULL; } if (webui->post_info != NULL) { free(webui->post_info); + webui->post_info = NULL; } - webui->post_info = NULL; delete webui; @@ -524,14 +524,14 @@ static mhdrslt webu_mhd_digest(struct ctx_webui *webui) webu_failauth_log(webui); if (user != NULL) { free(user); + user = NULL; } - user = NULL; return webu_mhd_digest_fail(webui, MHD_NO); } if (user != NULL) { free(user); + user = NULL; } - user = NULL; /* Check the password as well*/ retcd = MHD_digest_auth_check(webui->connection, webui->auth_realm @@ -592,12 +592,12 @@ static mhdrslt webu_mhd_basic(struct ctx_webui *webui) if ((user == NULL) || (pass == NULL)) { if (user != NULL) { free(user); + user = NULL; } - user = NULL; if (pass != NULL) { free(pass); + pass = NULL; } - pass = NULL; return webu_mhd_basic_fail(webui); } @@ -605,23 +605,23 @@ static mhdrslt webu_mhd_basic(struct ctx_webui *webui) webu_failauth_log(webui); if (user != NULL) { free(user); + user = NULL; } - user = NULL; if (pass != NULL) { free(pass); + pass = NULL; } - pass = NULL; return webu_mhd_basic_fail(webui); } if (user != NULL) { free(user); + user = NULL; } - user = NULL; if (pass != NULL) { free(pass); + pass = NULL; } - pass = NULL; webui->authenticated = true; @@ -637,12 +637,12 @@ static void webu_mhd_auth_parse(struct ctx_webui *webui) if (webui->auth_user != NULL) { free(webui->auth_user); + webui->auth_user = NULL; } - webui->auth_user = NULL; if (webui->auth_pass != NULL) { free(webui->auth_pass); + webui->auth_pass = NULL; } - webui->auth_pass = NULL; auth_len = webui->motapp->cam_list[0]->conf->webcontrol_authentication.length(); col_pos =(char*) strstr(webui->motapp->cam_list[0]->conf->webcontrol_authentication.c_str() ,":"); @@ -1460,14 +1460,14 @@ void webu_deinit(struct ctx_motapp *motapp) util_parms_free(motapp->webcontrol_headers); if (motapp->webcontrol_headers != NULL) { free(motapp->webcontrol_headers); + motapp->webcontrol_headers = NULL; } - motapp->webcontrol_headers = NULL; util_parms_free(motapp->webcontrol_actions); if (motapp->webcontrol_actions != NULL) { free(motapp->webcontrol_actions); + motapp->webcontrol_actions = NULL; } - motapp->webcontrol_actions = NULL; } diff --git a/src/webu_stream.cpp b/src/webu_stream.cpp index d2d2dec2..4aa34148 100644 --- a/src/webu_stream.cpp +++ b/src/webu_stream.cpp @@ -34,8 +34,8 @@ static void webu_stream_mjpeg_checkbuffers(struct ctx_webui *webui) if (webui->resp_image != NULL) { if (webui->resp_image != NULL) { free(webui->resp_image); + webui->resp_image = NULL; } - webui->resp_image = NULL; } webui->resp_image =(char*) mymalloc(webui->cam->imgs.size_norm); memset(webui->resp_image,'\0',webui->cam->imgs.size_norm); @@ -496,33 +496,33 @@ void webu_stream_deinit(struct ctx_cam *cam) if (cam->imgs.image_substream != NULL) { free(cam->imgs.image_substream); + cam->imgs.image_substream = NULL; } - cam->imgs.image_substream = NULL; if (cam->stream.norm.jpeg_data != NULL) { free(cam->stream.norm.jpeg_data); + cam->stream.norm.jpeg_data = NULL; } - cam->stream.norm.jpeg_data = NULL; if (cam->stream.sub.jpeg_data != NULL) { free(cam->stream.sub.jpeg_data); + cam->stream.sub.jpeg_data = NULL; } - cam->stream.sub.jpeg_data = NULL; if (cam->stream.motion.jpeg_data != NULL) { free(cam->stream.motion.jpeg_data); + cam->stream.motion.jpeg_data = NULL; } - cam->stream.motion.jpeg_data = NULL; if (cam->stream.source.jpeg_data != NULL) { free(cam->stream.source.jpeg_data); + cam->stream.source.jpeg_data = NULL; } - cam->stream.source.jpeg_data = NULL; if (cam->stream.secondary.jpeg_data != NULL) { free(cam->stream.secondary.jpeg_data); + cam->stream.secondary.jpeg_data = NULL; } - cam->stream.secondary.jpeg_data = NULL; } @@ -649,8 +649,8 @@ static void webu_stream_getimg_secondary(struct ctx_cam *cam) } else { if (cam->stream.secondary.jpeg_data != NULL) { free(cam->stream.secondary.jpeg_data); + cam->stream.secondary.jpeg_data = NULL; } - cam->stream.secondary.jpeg_data = NULL; } }