[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: bio: fix memory leak (#7590)
From: |
gnunet |
Subject: |
[gnunet] branch master updated: bio: fix memory leak (#7590) |
Date: |
Mon, 16 Jan 2023 09:35:48 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 31dcac7e2 bio: fix memory leak (#7590)
31dcac7e2 is described below
commit 31dcac7e27e676a3bd00b8359806cb598d10696a
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Jan 16 09:35:35 2023 +0100
bio: fix memory leak (#7590)
---
src/util/bio.c | 17 ++++++++++-------
src/util/test_bio.c | 14 +++++++++-----
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/src/util/bio.c b/src/util/bio.c
index 70620aea7..71d0ef7fc 100644
--- a/src/util/bio.c
+++ b/src/util/bio.c
@@ -182,8 +182,9 @@ GNUNET_BIO_read_close (struct GNUNET_BIO_ReadHandle *h,
char **emsg)
return err;
}
+
void
-GNUNET_BIO_read_set_error (struct GNUNET_BIO_ReadHandle *h, const char* emsg)
+GNUNET_BIO_read_set_error (struct GNUNET_BIO_ReadHandle *h, const char*emsg)
{
GNUNET_assert (NULL == h->emsg);
h->emsg = GNUNET_strdup (emsg);
@@ -380,7 +381,6 @@ GNUNET_BIO_read_string (struct GNUNET_BIO_ReadHandle *h,
}
-
/**
* Read a float.
*
@@ -553,8 +553,9 @@ GNUNET_BIO_write_open_buffer (void)
* if the handle has an error message, the return value is
#GNUNET_SYSERR
* @return #GNUNET_OK on success, #GNUNET_SYSERR otherwise
*/
-int
-GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h, char **emsg)
+enum GNUNET_GenericReturnValue
+GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h,
+ char **emsg)
{
int err;
@@ -567,7 +568,10 @@ GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h,
char **emsg)
{
case IO_FILE:
if (NULL == h->fd)
- return GNUNET_SYSERR;
+ {
+ err = GNUNET_SYSERR;
+ break;
+ }
if (GNUNET_OK != GNUNET_BIO_flush (h))
{
if (NULL != emsg)
@@ -600,7 +604,7 @@ GNUNET_BIO_write_close (struct GNUNET_BIO_WriteHandle *h,
char **emsg)
* @return #GNUNET_OK upon success. Upon failure #GNUNET_SYSERR is returned
* and the file is closed
*/
-int
+enum GNUNET_GenericReturnValue
GNUNET_BIO_flush (struct GNUNET_BIO_WriteHandle *h)
{
ssize_t ret;
@@ -793,7 +797,6 @@ GNUNET_BIO_write_string (struct GNUNET_BIO_WriteHandle *h,
}
-
/**
* Write a float.
*
diff --git a/src/util/test_bio.c b/src/util/test_bio.c
index 90f0121d4..950dd1142 100644
--- a/src/util/test_bio.c
+++ b/src/util/test_bio.c
@@ -25,7 +25,6 @@
*/
-
#include "platform.h"
#include "gnunet_util_lib.h"
#define TESTSTRING "testString"
@@ -64,9 +63,14 @@ test_normal_rw (void)
rh = GNUNET_BIO_read_open_file (filename);
GNUNET_assert (NULL != rh);
- GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_spec_commit (rh, rs));
- GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_close (rh, NULL));
- GNUNET_assert (0 == strcmp (TESTSTRING, rString));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_BIO_read_spec_commit (rh,
+ rs));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_BIO_read_close (rh,
+ NULL));
+ GNUNET_assert (0 == strcmp (TESTSTRING,
+ rString));
GNUNET_assert (wNum == rNum);
GNUNET_assert (GNUNET_OK == GNUNET_DISK_directory_remove (filename));
@@ -89,7 +93,7 @@ test_normal_rw (void)
GNUNET_assert (GNUNET_OK == GNUNET_BIO_read_close (rh, NULL));
GNUNET_assert (0 == strcmp (TESTSTRING, rString));
GNUNET_assert (wNum == rNum);
-
+ GNUNET_free (rString);
GNUNET_free (buffer);
return 0;
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: bio: fix memory leak (#7590),
gnunet <=