Plug minor leaks in string conversion routines.

This commit is contained in:
Fernando Tarlá Cardoso Lemos 2011-11-06 20:01:25 -02:00 committed by Michael Stapelberg
parent ddf261432a
commit d5613905c8
3 changed files with 5 additions and 0 deletions

View File

@ -47,6 +47,7 @@ char *convert_ucs_to_utf8(char *input) {
/* Convert our text */ /* Convert our text */
int rc = iconv(conversion_descriptor, (void*)&input, &input_size, &output, &output_size); int rc = iconv(conversion_descriptor, (void*)&input, &input_size, &output, &output_size);
if (rc == (size_t)-1) { if (rc == (size_t)-1) {
free(buffer);
perror("Converting to UCS-2 failed"); perror("Converting to UCS-2 failed");
return NULL; 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); int rc = iconv(conversion_descriptor2, (void*)&input, &input_size, &output, &output_size);
if (rc == (size_t)-1) { if (rc == (size_t)-1) {
perror("Converting to UCS-2 failed"); perror("Converting to UCS-2 failed");
free(buffer);
if (real_strlen != NULL) if (real_strlen != NULL)
*real_strlen = 0; *real_strlen = 0;
return NULL; return NULL;

View File

@ -49,6 +49,7 @@ char *convert_ucs_to_utf8(char *input) {
int rc = iconv(conversion_descriptor, (void*)&input, &input_size, &output, &output_size); int rc = iconv(conversion_descriptor, (void*)&input, &input_size, &output, &output_size);
if (rc == (size_t)-1) { if (rc == (size_t)-1) {
perror("Converting to UCS-2 failed"); perror("Converting to UCS-2 failed");
free(buffer);
return NULL; 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); int rc = iconv(conversion_descriptor2, (void*)&input, &input_size, &output, &output_size);
if (rc == (size_t)-1) { if (rc == (size_t)-1) {
perror("Converting to UCS-2 failed"); perror("Converting to UCS-2 failed");
free(buffer);
if (real_strlen != NULL) if (real_strlen != NULL)
*real_strlen = 0; *real_strlen = 0;
return NULL; return NULL;

View File

@ -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); int rc = iconv(conversion_descriptor, (void*)&input, &input_size, &output, &output_size);
if (rc == (size_t)-1) { if (rc == (size_t)-1) {
perror("Converting to UCS-2 failed"); perror("Converting to UCS-2 failed");
FREE(buffer);
if (real_strlen != NULL) if (real_strlen != NULL)
*real_strlen = 0; *real_strlen = 0;
return NULL; return NULL;