Protect against resource leaks.
Signed-off-by: Erik Hovland <erik@hovland.org> Signed-off-by: Dan Dennedy <dan@dennedy.org>
This commit is contained in:
parent
378b935fa3
commit
709d8791ce
|
@ -48,7 +48,10 @@ raw1394handle_t raw1394_new_handle(void)
|
||||||
else if (handle) {
|
else if (handle) {
|
||||||
handle->is_fw = 1;
|
handle->is_fw = 1;
|
||||||
handle->mode.fw = fw_handle;
|
handle->mode.fw = fw_handle;
|
||||||
}
|
} else if (fw_handle)
|
||||||
|
fw_destroy_handle(fw_handle);
|
||||||
|
else if (ieee1394_handle)
|
||||||
|
ieee1394_destroy_handle(ieee1394_handle);
|
||||||
}
|
}
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
@ -76,14 +79,16 @@ raw1394handle_t raw1394_new_handle_on_port(int port)
|
||||||
if (handle) {
|
if (handle) {
|
||||||
handle->is_fw = 0;
|
handle->is_fw = 0;
|
||||||
handle->mode.ieee1394 = ieee1394_handle;
|
handle->mode.ieee1394 = ieee1394_handle;
|
||||||
}
|
} else
|
||||||
|
ieee1394_destroy_handle(ieee1394_handle);
|
||||||
}
|
}
|
||||||
else if (fw_handle = fw_new_handle_on_port(port)) {
|
else if (fw_handle = fw_new_handle_on_port(port)) {
|
||||||
handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
|
handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
|
||||||
if (handle) {
|
if (handle) {
|
||||||
handle->is_fw = 1;
|
handle->is_fw = 1;
|
||||||
handle->mode.fw = fw_handle;
|
handle->mode.fw = fw_handle;
|
||||||
}
|
} else
|
||||||
|
fw_destroy_handle(fw_handle);
|
||||||
}
|
}
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
4
src/fw.c
4
src/fw.c
|
@ -501,8 +501,10 @@ fw_handle_t fw_new_handle_on_port(int port)
|
||||||
if (handle == NULL)
|
if (handle == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (fw_set_port(handle, port) < 0)
|
if (fw_set_port(handle, port) < 0) {
|
||||||
|
fw_destroy_handle(handle);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue