Share

tkImg

Tracker: Bugs

5 iptcutil.c: memory leak - ID: 2883109
Last Update: Tracker Item Submitted ( dcb314 )


For source code file tkimg1.3/libtiff/contrib/iptcutil/iptcutil.c
function formatIPTC

I notice the following code

str=(unsigned char *) malloc((unsigned int) (taglen+1));
if (str == (unsigned char *) NULL)
{
printf("Memory allocation failed");
return 0;
}
for (tagindx=0; tagindx<taglen; tagindx++)
{
c = str[tagindx] = getc(ifile);
if (c == EOF)
return -1;

so if the second return is taken, then str is a memory leak. Suggest
new code

str=(unsigned char *) malloc((unsigned int) (taglen+1));
if (str == (unsigned char *) NULL)
{
printf("Memory allocation failed");
return 0;
}
for (tagindx=0; tagindx<taglen; tagindx++)
{
c = str[tagindx] = getc(ifile);
if (c == EOF)
{
free( str);
return -1;
}


dcb ( dcb314 ) - 2009-10-21 09:14

5

Open

None

Nobody/Anonymous

None

None

Public


Comments

No follow-up comments have been posted.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.