Add checks for memory allocation failures. Patch from Mandriva folks by

Gustavo De Nardin via Vincent Danen. Originally for libcdio 0.78.2

See also https://savannah.gnu.org/patch/?6413
This commit is contained in:
rocky
2008-02-08 08:53:32 +00:00
parent 599b88fd14
commit 2e34115075
2 changed files with 59 additions and 9 deletions

View File

@@ -140,11 +140,17 @@ do_convert(iconv_t cd, char * src, int src_len,
outbytesleft += BYTES_INCREMENT;
ret = realloc(ret, alloc_size);
if (ret == NULL)
{
fprintf(stderr, "Can't realloc(%d).\n", alloc_size);
return false;
}
outbuf = ret + output_pos;
break;
default:
fprintf(stderr, "Iconv failed: %s\n", strerror(errno));
free(ret);
if (ret != NULL)
free(ret);
return false;
break;
}