From d5613905c817637b5928526f10b866bd67b410e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fernando=20Tarl=C3=A1=20Cardoso=20Lemos?= Date: Sun, 6 Nov 2011 20:01:25 -0200 Subject: [PATCH] Plug minor leaks in string conversion routines. --- i3-input/ucs2_to_utf8.c | 2 ++ i3bar/src/ucs2_to_utf8.c | 2 ++ src/util.c | 1 + 3 files changed, 5 insertions(+) diff --git a/i3-input/ucs2_to_utf8.c b/i3-input/ucs2_to_utf8.c index 4d73493c..df112eef 100644 --- a/i3-input/ucs2_to_utf8.c +++ b/i3-input/ucs2_to_utf8.c @@ -47,6 +47,7 @@ char *convert_ucs_to_utf8(char *input) { /* Convert our text */ int rc = iconv(conversion_descriptor, (void*)&input, &input_size, &output, &output_size); if (rc == (size_t)-1) { + free(buffer); perror("Converting to UCS-2 failed"); return NULL; } @@ -85,6 +86,7 @@ char *convert_utf8_to_ucs2(char *input, int *real_strlen) { int rc = iconv(conversion_descriptor2, (void*)&input, &input_size, &output, &output_size); if (rc == (size_t)-1) { perror("Converting to UCS-2 failed"); + free(buffer); if (real_strlen != NULL) *real_strlen = 0; return NULL; diff --git a/i3bar/src/ucs2_to_utf8.c b/i3bar/src/ucs2_to_utf8.c index 7797dc1f..642a72fb 100644 --- a/i3bar/src/ucs2_to_utf8.c +++ b/i3bar/src/ucs2_to_utf8.c @@ -49,6 +49,7 @@ char *convert_ucs_to_utf8(char *input) { int rc = iconv(conversion_descriptor, (void*)&input, &input_size, &output, &output_size); if (rc == (size_t)-1) { perror("Converting to UCS-2 failed"); + free(buffer); return NULL; } @@ -88,6 +89,7 @@ char *convert_utf8_to_ucs2(char *input, int *real_strlen) { int rc = iconv(conversion_descriptor2, (void*)&input, &input_size, &output, &output_size); if (rc == (size_t)-1) { perror("Converting to UCS-2 failed"); + free(buffer); if (real_strlen != NULL) *real_strlen = 0; return NULL; diff --git a/src/util.c b/src/util.c index f894eb3f..72146bff 100644 --- a/src/util.c +++ b/src/util.c @@ -153,6 +153,7 @@ char *convert_utf8_to_ucs2(char *input, int *real_strlen) { int rc = iconv(conversion_descriptor, (void*)&input, &input_size, &output, &output_size); if (rc == (size_t)-1) { perror("Converting to UCS-2 failed"); + FREE(buffer); if (real_strlen != NULL) *real_strlen = 0; return NULL; -- 2.39.5