Skip to content

Commit d7f9924

Browse files
committed
vcap/aggregate fixes
- fixed a leak of s->devices (CID 472157) - fix partial display_done (when eg. second device from 2 fail to init, do not call the vidcap_done on this - assumes non-NULL) - remove s!=NULL after assertion on that
1 parent c929520 commit d7f9924

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/video_capture/aggregate.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct vidcap_params;
5656

5757
/* prototypes of functions defined in this module */
5858
static void show_help(void);
59+
static void vidcap_aggregate_done(void *state);
5960

6061
static void show_help()
6162
{
@@ -146,15 +147,7 @@ vidcap_aggregate_init(struct vidcap_params *params, void **state)
146147
return VIDCAP_INIT_OK;
147148

148149
error:
149-
if(s->devices) {
150-
int i;
151-
for (i = 0u; i < s->devices_cnt; ++i) {
152-
if(s->devices[i]) {
153-
vidcap_done(s->devices[i]);
154-
}
155-
}
156-
}
157-
free(s);
150+
vidcap_aggregate_done(s);
158151
return VIDCAP_INIT_FAIL;
159152
}
160153

@@ -165,13 +158,12 @@ vidcap_aggregate_done(void *state)
165158

166159
assert(s != NULL);
167160

168-
if (s != NULL) {
169-
int i;
170-
for (i = 0; i < s->devices_cnt; ++i) {
171-
vidcap_done(s->devices[i]);
172-
}
173-
}
174-
161+
for (int i = 0; i < s->devices_cnt; ++i) {
162+
if (s->devices[i] != NULL) {
163+
vidcap_done(s->devices[i]);
164+
}
165+
}
166+
175167
vf_free(s->frame);
176168
free(s);
177169
}

0 commit comments

Comments
 (0)