summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Erik Hovland 2008-09-30 14:05:32 -0700
committerGravatar Dan Dennedy 2008-10-28 22:52:06 -0700
commit709d8791ceadae2c2a0cd3ef9ebdf56e4d7dd27e (patch)
tree4abb2023378f4761df8b482e66c570b4e3915c6f
parentMake sure variables are initialized before used. (diff)
Protect against resource leaks.
Signed-off-by: Erik Hovland <erik@hovland.org> Signed-off-by: Dan Dennedy <dan@dennedy.org>
-rw-r--r--src/dispatch.c11
-rw-r--r--src/fw.c4
2 files changed, 11 insertions, 4 deletions
diff --git a/src/dispatch.c b/src/dispatch.c
index 6786a52..567fbbc 100644
--- a/src/dispatch.c
+++ b/src/dispatch.c
@@ -48,7 +48,10 @@ raw1394handle_t raw1394_new_handle(void)
else if (handle) {
handle->is_fw = 1;
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;
}
@@ -76,14 +79,16 @@ raw1394handle_t raw1394_new_handle_on_port(int port)
if (handle) {
handle->is_fw = 0;
handle->mode.ieee1394 = ieee1394_handle;
- }
+ } else
+ ieee1394_destroy_handle(ieee1394_handle);
}
else if (fw_handle = fw_new_handle_on_port(port)) {
handle = (raw1394handle_t) malloc(sizeof(struct raw1394_handle));
if (handle) {
handle->is_fw = 1;
handle->mode.fw = fw_handle;
- }
+ } else
+ fw_destroy_handle(fw_handle);
}
return handle;
}
diff --git a/src/fw.c b/src/fw.c
index 3c61385..a229d1a 100644
--- a/src/fw.c
+++ b/src/fw.c
@@ -501,8 +501,10 @@ fw_handle_t fw_new_handle_on_port(int port)
if (handle == NULL)
return NULL;
- if (fw_set_port(handle, port) < 0)
+ if (fw_set_port(handle, port) < 0) {
+ fw_destroy_handle(handle);
return NULL;
+ }
return handle;
}
e='2003-04-23 04:31:28 +0000'>2003-04-23add libtoolize to bootstrapGravatar ddennedy 1-1/+10 2003-04-21added Dan Maas' rawiso docsGravatar ddennedy 1-32/+295 2003-04-07new_handle_on_port() error path fix from Jim RadfordGravatar dmaas 1-1/+3 2003-03-26add raw1394_new_handle_on_port() convenience functionGravatar dmaas 2-1/+41 2003-02-22Updates for new rawiso ioctl interface.Gravatar bencollins 3-37/+125 2003-01-15add iso_xmit_sync() and iso_xmit_write(); clean up iso handling a bitGravatar dmaas 5-39/+161 2003-01-15implement tag matching for rawiso receptionGravatar dmaas 3-4/+12 2003-01-06back out previous commit - don't drop the legacy API just yetGravatar dmaas 6-173/+130 2003-01-05emulate legacy ISO reception API on top of new rawiso APIGravatar dmaas 7-131/+174 2002-12-24update iso API for multi-channel reception and new packet buffer layoutGravatar dmaas 4-123/+236 2002-12-20oops, irq_interval needs to be signedGravatar anonymous 1-1/+1 2002-12-20dmaas - renamed exported arm definitions into the raw1394_ namespace; brought...Gravatar anonymous 3-124/+48 2002-12-16rawiso updates:Gravatar dmaas 3-18/+25 2002-11-18fix cplusplus extern C blockGravatar ddennedy 1-4/+4 2002-11-18merged rawiso branchGravatar ddennedy 7-6/+488