diff options
| author | 2008-07-06 12:06:40 -0700 | |
|---|---|---|
| committer | 2008-07-06 12:06:40 -0700 | |
| commit | 8f942654d9c2b9cd957e8e1f7eb1f29a05bbf64a (patch) | |
| tree | 3cdb6f52867ee18af06f7e478fcaa9e15e7a8510 /src/eventloop.c | |
| parent | Fix raw1394_read_cycle_timer after juju integration (diff) | |
Change handle validation to prevent segfault and be more informative.
Diffstat (limited to 'src/eventloop.c')
| -rw-r--r-- | src/eventloop.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/eventloop.c b/src/eventloop.c index 78e581a..43a9519 100644 --- a/src/eventloop.c +++ b/src/eventloop.c @@ -97,7 +97,11 @@ bus_reset_handler_t raw1394_set_bus_reset_handler(struct raw1394_handle *handle, bus_reset_handler_t new) { bus_reset_handler_t old; - if (handle && handle->is_fw) { + if (!handle) { + errno = EINVAL; + return NULL; + } + if (handle->is_fw) { old = handle->mode.fw->bus_reset_handler; handle->mode.fw->bus_reset_handler = new; } @@ -112,7 +116,11 @@ tag_handler_t raw1394_set_tag_handler(struct raw1394_handle *handle, tag_handler_t new) { tag_handler_t old; - if (handle && handle->is_fw) { + if (!handle) { + errno = EINVAL; + return NULL; + } + if (handle->is_fw) { old = handle->mode.fw->tag_handler; handle->mode.fw->tag_handler = new; } @@ -127,7 +135,11 @@ arm_tag_handler_t raw1394_set_arm_tag_handler(struct raw1394_handle *handle, arm_tag_handler_t new) { arm_tag_handler_t old; - if (handle && handle->is_fw) { + if (!handle) { + errno = EINVAL; + return NULL; + } + if (handle->is_fw) { old = handle->mode.fw->arm_tag_handler; handle->mode.fw->arm_tag_handler = new; } @@ -142,7 +154,11 @@ fcp_handler_t raw1394_set_fcp_handler(struct raw1394_handle *handle, fcp_handler_t new) { fcp_handler_t old; - if (handle && handle->is_fw) { + if (!handle) { + errno = EINVAL; + return NULL; + } + if (handle->is_fw) { old = handle->mode.fw->fcp_handler; handle->mode.fw->fcp_handler = new; } |
