From: Fernando Tarlá Cardoso Lemos Date: Sun, 6 Nov 2011 22:01:25 +0000 (-0200) Subject: Plug minor leaks in string conversion routines. X-Git-Tag: 4.1~30 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d5613905c817637b5928526f10b866bd67b410e2;p=i3%2Fi3 Plug minor leaks in string conversion routines. --- 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;