summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-11-14 18:18:49 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-11-14 18:18:49 +0000
commitfc03565db71241cbc0a47ae7528273d3982fb606 (patch)
tree2c676f8ff250925b300e725eadb0080aae58b52c
parentcc4b382592d9f12fea4791c8f32aff755cb547a1 (diff)
Fixed memory leak
-rw-r--r--hcid/dbus-sdp.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/hcid/dbus-sdp.c b/hcid/dbus-sdp.c
index 48fc6ba2..9701a31d 100644
--- a/hcid/dbus-sdp.c
+++ b/hcid/dbus-sdp.c
@@ -227,7 +227,7 @@ static const char *get_address_from_message(DBusConnection *conn, DBusMessage *m
static int sdp_store_record(const char *src, const char *dst, uint32_t handle, uint8_t *buf, size_t size)
{
char filename[PATH_MAX + 1], key[28], *value;
- int i;
+ int i, status = 0;
create_name(filename, PATH_MAX, STORAGEDIR, src, "sdp");
@@ -244,7 +244,12 @@ static int sdp_store_record(const char *src, const char *dst, uint32_t handle, u
for (i = 0; i < size; i++)
sprintf(value + (i * 2), "%02X", buf[i]);
- return textfile_put(filename, key, value);
+ if (textfile_put(filename, key, value) < 0)
+ status = -errno;
+
+ free(value);
+
+ return status;
}
static void transaction_context_free(void *udata)
@@ -403,6 +408,8 @@ static void remote_svc_rec_completed_cb(uint8_t type, uint16_t err, uint8_t *rsp
sdp_store_record(src, dst, rec->handle, rsp, size);
+ sdp_record_free(rec);
+
for (i = 0; i < size; i++)
dbus_message_iter_append_basic(&array_iter,
DBUS_TYPE_BYTE, &rsp[i]);
@@ -475,6 +482,8 @@ static void remote_svc_rec_completed_xml_cb(uint8_t type, uint16_t err,
convert_sdp_record_to_xml(rec, &result, append_and_grow_string);
+ sdp_record_free(rec);
+
if (result.data) {
dbus_message_append_args(reply,
DBUS_TYPE_STRING, &result.data,
@@ -869,12 +878,9 @@ static void get_rec_with_handle_comp_cb(uint8_t type, uint16_t err,
goto failed;
}
- /* FIXME: add record to the cache! */
-
failed:
get_record_data_call_cb(ctxt->priv, rec, cb_err);
- /* FIXME: when start using cache don't free the service record */
if (rec)
sdp_record_free(rec);
@@ -924,8 +930,6 @@ int get_record_with_handle(DBusConnection *conn, DBusMessage *msg,
uint32_t *rec_handle;
int err;
- /* FIXME: search the cache first! */
-
if (find_pending_connect(dst)) {
error("SDP search in progress!");
return -EINPROGRESS;
@@ -1055,8 +1059,6 @@ int get_record_with_uuid(DBusConnection *conn, DBusMessage *msg,
int err;
uuid_t *sdp_uuid;
- /* FIXME: search the cache first! */
-
if (find_pending_connect(dst)) {
error("SDP search in progress!");
return -EINPROGRESS;