Fix leaks in obex
PATCH 2/6 Fix leaks in obex
In filesystem, g_file_get_contents allocates fresh memory. Use it instead of making a new copy of it. That saves having to free buf later.
Destination was missed on an error path as is mld.
Signed-off-by Steve Grubb <[email protected]>
--- obexd/plugins/filesystem.c | 2 +- obexd/plugins/ftp.c | 8 ++++++-- obexd/plugins/messages-dummy.c | 1 + 3 files changed, 8 insertions(+), 3 deletions(-)
obexd/plugins/filesystem.c +1 -1
@@ -415,7 +415,7 @@ static void *capability_open(const char *name, int oflag, mode_t mode, goto fail; } - object->buffer =g_string_new (buf); + object->buffer = buf;if (size) *size = object->buffer->len;
obexd/plugins/ftp.c +6 -2
@@ -386,8 +386,10 @@ static int ftp_copy(struct ftp_session *ftp, const char *name, ret =verify_path (destdir);g_free (destdir); -if (ret <0 ) +if (ret <0 ) { +g_free (destination);return ret; + } source =g_build_filename (ftp->folder, name,NULL );
@@ -424,8 +426,10 @@ static int ftp_move(struct ftp_session *ftp, const char *name, ret =verify_path (destdir);g_free (destdir); -if (ret <0 ) +if (ret <0 ) { +g_free (destination);return ret; + } source =g_build_filename (ftp->folder, name,NULL );
obexd/plugins/messages-dummy.c +1 -0
@@ -488,6 +488,7 @@ int messages_get_messages_listing(void *session, const char *name,int err = -errno;DBG ("fopen(): %d, %s" , -err,strerror (-err));g_free (path); +g_free (mld);return -EBADR ; } }
Signature · 1 line
2.31.1