visionstream: fix doube fd close (#2057)

* s->ipc_fd counld be closed twice

* white space
pull/2073/head
Dean Lee 2020-08-24 20:07:27 +08:00 committed by GitHub
parent 727055e0a0
commit 17dd07e751
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -90,6 +90,7 @@ int visionstream_init(VisionStream *s, VisionStreamType type, bool tbuffer, Visi
err = vipc_send(s->ipc_fd, &p);
if (err < 0) {
close(s->ipc_fd);
s->ipc_fd = -1;
return -1;
}
@ -97,6 +98,7 @@ int visionstream_init(VisionStream *s, VisionStreamType type, bool tbuffer, Visi
err = vipc_recv(s->ipc_fd, &rp);
if (err <= 0) {
close(s->ipc_fd);
s->ipc_fd = -1;
return -1;
}
assert(rp.type == VIPC_STREAM_BUFS);
@ -190,5 +192,5 @@ void visionstream_destroy(VisionStream *s) {
}
}
if (s->bufs) free(s->bufs);
close(s->ipc_fd);
if (s->ipc_fd >= 0) close(s->ipc_fd);
}