Ignore:
Timestamp:
May 11, 2023, 10:44:53 PM (2 years ago)
Author:
gyoung
Message:

Fix errors reported by CPPCheck

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JPGPROC/source/gbmsrc/gbmtifh.c

    r2 r57  
    310310        gbm_file_lseek(fd, offset_ifd, SEEK_SET);
    311311        while ( n_ifds_to_skip-- > 0 )
    312                 if ( !skip_ifd(fd, motorola) )
     312                if ( !skip_ifd(fd, motorola) ) {
     313                        ifh_free(ifh);
    313314                        return TE_N_IFD;
     315                }
    314316
    315317        if ( (ecode = read_ifd(fd, motorola, &(ifh->ifd))) != TE_OK )
     
    443445        if ( (byte_ptr = (byte *) malloc((size_t) (n * sizeof(byte)))) == NULL )
    444446                return FALSE;
    445         if ( (tag = get_tag_slot(type, ifd)) == NULL )
    446                 return FALSE;
     447        if ( (tag = get_tag_slot(type, ifd)) == NULL ) {
     448                free(byte_ptr);
     449                return FALSE;
     450        }
    447451        tag->type      = type;
    448452        tag->data_type = D_BYTE;
     
    452456                       value,
    453457                       n * sizeof(byte));
     458        free(byte_ptr);
    454459        return TRUE;
    455460        }
     
    465470        if ( (ascii_ptr = (char *) malloc((size_t) n)) == NULL )
    466471                return FALSE;
    467         if ( (tag = get_tag_slot(type, ifd)) == NULL )
    468                 return FALSE;
     472        if ( (tag = get_tag_slot(type, ifd)) == NULL ) {
     473                free(ascii_ptr);
     474                return FALSE;
     475        }
    469476        tag->type      = type;
    470477        tag->data_type = D_ASCII;
    471478        tag->length    = (long) n;
    472479        strcpy(tag->value = ascii_ptr, value);
     480        free(ascii_ptr);
    473481        return TRUE;
    474482        }
     
    482490        if ( (short_ptr = (short *) malloc((size_t) (n * sizeof(short)))) == NULL )
    483491                return FALSE;
    484         if ( (tag = get_tag_slot(type, ifd)) == NULL )
    485                 return FALSE;
     492        if ( (tag = get_tag_slot(type, ifd)) == NULL ) {
     493                free(short_ptr);
     494                return FALSE;
     495        }
    486496        tag->type      = type;
    487497        tag->data_type = D_SHORT;
     
    491501                       value,
    492502                       n * sizeof(short));
     503        free(short_ptr);
    493504        return TRUE;
    494505        }
     
    502513        if ( (long_ptr = (long *) malloc((size_t) (n * sizeof(long)))) == NULL )
    503514                return FALSE;
    504         if ( (tag = get_tag_slot(type, ifd)) == NULL )
    505                 return FALSE;
     515        if ( (tag = get_tag_slot(type, ifd)) == NULL ) {
     516                free(long_ptr);
     517                return FALSE;
     518        }
    506519        tag->type      = type;
    507520        tag->data_type = D_LONG;
     
    511524                       value,
    512525                       n * sizeof(long));
     526        free(long_ptr);
    513527        return TRUE;
    514528        }
     
    522536        if ( (rational_ptr = (rational *) malloc((size_t) (n * sizeof(rational)))) == NULL )
    523537                return FALSE;
    524         if ( (tag = get_tag_slot(type, ifd)) == NULL )
    525                 return FALSE;
     538        if ( (tag = get_tag_slot(type, ifd)) == NULL ) {
     539                free(rational_ptr);
     540                return FALSE;
     541        }
    526542        tag->type      = type;
    527543        tag->data_type = D_RATIONAL;
     
    531547                       value,
    532548                       n * sizeof(rational));
     549        free(rational_ptr);
    533550        return TRUE;
    534551        }
Note: See TracChangeset for help on using the changeset viewer.