Changeset 57


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

Fix errors reported by CPPCheck

Location:
trunk
Files:
20 edited

Legend:

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

    r2 r57  
    194194/*...shandle a filename argument:16:*/
    195195{
    196 char fn[500+1], *opt;
     196    char fn[500+1] = {0}, *opt;
    197197strncpy(fn, argv[i], 500);
    198198if ( (opt = strchr(fn, ',')) != NULL )
  • trunk/JPGPROC/source/gbmsrc/gbmlbm.c

    r2 r57  
    12181218        return rc;
    12191219
    1220 for ( i = 0; i <= 0x10; i++ )
     1220for ( i = 0; i < 0x10; i++ )
    12211221        gbmrgb_grey[i].r = gbmrgb_grey[i].g = gbmrgb_grey[i].b = (byte) (i * 0x11);
    12221222
  • trunk/JPGPROC/source/gbmsrc/gbmsize.c

    r2 r57  
    112112        int     w = -1, h = -1;
    113113        char    fn_src[500+1], fn_dst[500+1], *opt_src, *opt_dst;
    114         int     fd, ft_src, ft_dst, i, stride, stride2, flag;
     114        int     fd = 0, ft_src, ft_dst, i, stride, stride2, flag;
    115115        GBM_ERR rc;
    116116        GBMFT   gbmft;
  • 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        }
  • trunk/JPGPROC/source/gbmsrc/x.c

    r2 r57  
    148148                ys[i] = ys[i+1] - ys[i];
    149149
    150 
     150        }
    151151
    152152static void simple_scale_8(
  • trunk/JPGPROC/source/jpgproc.c

    r2 r57  
    655655
    656656            MMIMAGEHEADER   MMImgHdr;
    657             ULONG           ulWidth;
    658             ULONG           ulHeight;
     657            ULONG           ulWidth = 0;
     658            ULONG           ulHeight = 0;
    659659            PBYTE           lpRGBBufPtr;
    660660
  • trunk/classes/c/c_audio/cwastream.c

    r3 r57  
    7575     
    7676      if(!fgets(chrBuf, ulBufSize, fStream)) {
    77         fclose(fStream);
     77        // Fixme double deallocation is this missing a break;
     78        //fclose(fStream);
    7879        sprintf(chrBuf, DEFAULT_AUDIOSTREAM_SERVER);
    7980      }
  • trunk/classes/c/c_common/helper.c

    r49 r57  
    6262  HAPP         happ;
    6363  HWND hwndAppTerminateHandler;
    64   char startupDir[CCHMAXPATH];
     64  char startupDir[CCHMAXPATH] = {0};
    6565  char *chrPtr;
    6666
     
    7373  pDetails.pszParameters   = parameters;
    7474  /* Set the startup directory to the location of the executable */
    75   strncpy(startupDir, wrapperExe, sizeof(startupDir));
     75  strncpy(startupDir, wrapperExe, sizeof(startupDir) - 1);
    7676  //  SysWriteToTrapLog("1: %s %s\n", startupDir, wrapperExe);
    7777  if((chrPtr=strrchr(startupDir,'\\'))!=NULLHANDLE) {
  • trunk/classes/c/c_image/cwbmp.c

    r2 r57  
    706706    if(ppDetailsData)
    707707      {
    708         ULONG ulWidth, ulHeight, ulDepth;
     708        ULONG ulWidth = 0, ulHeight = 0, ulDepth = 0;
    709709        PBITMAPINFOHEADER2 pBmpInfoHeader2;       
    710710       
     
    725725        }
    726726       
    727         /* Fill the structure with the info to be displayed */     
     727        /* Fill the structure with the info to be displayed */
     728        // Fixme ulWidth and freinds are potentally uninitulized is the } above in the wrong place
    728729        pImageDetails=(PIMAGEDETAILS)*ppDetailsData; 
    729730        pImageDetails->ulWidth=ulWidth;
  • trunk/classes/c/c_mm/cwmmdisk.c

    r2 r57  
    9797                if((hObject=WinQueryObject(chrPlayerID))!=NULLHANDLE) {
    9898                  WPObject *wpObject;
    99                   HWND hwnd;
     99                  HWND hwnd = 0;
    100100                  wpObject=_wpclsQueryObject( _CWMMDisk , hObject);
    101101                  if(somIsObj(wpObject)) {
  • trunk/classes/c/c_mm/mmfolder.c

    r2 r57  
    358358              if((somIsObj(cwImageClass)||somIsObj(cwBitmapClass)) && !(_wpQueryStyle(wpObject) & OBJSTYLE_TEMPLATE)) {
    359359                HBITMAP hbm=NULLHANDLE;
    360                 PBITMAPINFOHEADER2 pBmpInfoHeader2;
     360                PBITMAPINFOHEADER2 pBmpInfoHeader2=NULLHANDLE;
    361361#ifdef DEBUG
    362362                SysWriteToTrapLog("Object is an image. (%s line: %d)\n", __FUNCTION__, __LINE__);
  • trunk/classes/mm-progs/MMPlayer/playaudio.c

    r4 r57  
    123123  ULONG rc;
    124124  int iWavePriv;
    125   int iTime2;
     125  int iTime2 = 0;
    126126  HWND hwndNotify;
    127127
  • trunk/classes/mm-progs/_MMBROWSE/mmbrowse.c

    r2 r57  
    12591259                    PSZ  pszFileName)
    12601260{
    1261     HBITMAP hBmp;
     1261    HBITMAP hBmp = 0;
    12621262    BOOL    bReturnCode;
    12631263
  • trunk/classes/mm-progs/_pmtst/volume.c

    r2 r57  
    929929  if(ulFileSize!=fread(pData, sizeof(BYTE), ulFileSize, file))
    930930    {
    931       free(pData);
     931      free(pData);
     932      fclose(file);
    932933      return NULLHANDLE;
    933934    }
  • trunk/classes/mm-progs/videoplayer/playaudio.c

    r2 r57  
    130130  ULONG rc;
    131131  int iWavePriv;
    132   int iTime2;
     132  int iTime2 = 0;
    133133  HWND hwndNotify;
    134134
  • trunk/mediafolder/c/cddb/cddbcls.cpp

    r2 r57  
    146146void printError(char* errorString)
    147147{
    148   char buffer[CCHMAXPATH];
     148    char buffer[CCHMAXPATH] = {0};
    149149  char *ptr;
    150150
    151   strncpy(buffer, errorString, sizeof(buffer));
     151  strncpy(buffer, errorString, sizeof(buffer) - 1);
    152152  fprintf(stderr,"%s",errorString);
    153153  /* hwndError is global, so this isn't threadsafe */
  • trunk/mediafolder/c/helper/cddbhelper.cpp

    r2 r57  
    4040void extern printError(char* errorString)
    4141{
    42   char buffer[CCHMAXPATH];
     42    char buffer[CCHMAXPATH] = {0};
    4343  char *ptr;
    4444
     
    4747  writeLog(errorString);
    4848  if(hwndError) {
    49     strncpy(buffer, errorString, sizeof(buffer));
     49    strncpy(buffer, errorString, sizeof(buffer) - 1);
    5050    ptr=strchr(buffer,'\n');
    5151    if(ptr) {
  • trunk/mediafolder/c/helper/launchpad.cpp

    r2 r57  
    557557        static HWND hwndBubbleClient;
    558558        ULONG style=FCF_BORDER|FCF_NOBYTEALIGN;
    559         char winText[255];
     559        char winText[255] = {0};
    560560       
    561561        /* Get window text for size calculating */
     
    10281028    if(somIsObj(folderClass))
    10291029      wpFolder=(WPFolder*)((M_WPFolder*)folderClass)->wpclsQueryFolder(chrConfigID, FALSE);
    1030   }
    1031 
     1030    if(!somIsObj(wpFolder))
     1031      return FALSE;
     1032  }
     1033  else
     1034    return FALSE;
     1035
     1036  // Fixme see line 1106
    10321037  ulBufferSize=sizeof(chrPath);
    10331038  wpFolder->wpQueryRealName(chrPath, &ulBufferSize, TRUE);
     
    11011106      return FALSE;
    11021107  }
    1103  
     1108  else
     1109    return FALSE;
     1110  // Fixme wpFolder can be uninittailized if(somIsObj(wpParentFolder)) is false sould we return FALSE
    11041111  /* Build ini name */
    11051112  ulBufferSize=sizeof(chrPath);
  • trunk/mediafolder/c/mediafldr/mediafolder.cpp

    r2 r57  
    867867static int _getRandomTrack(  MEDIAFLDRDATA* mfData)
    868868{
    869   int zufall;
     869  int zufall = 0;
    870870  DATETIME DT;
    871871  INT  seed, start,  iCheck=0;
     
    928928  ULONG rc;
    929929  int iWavePriv;
    930   int iTime2;
     930  int iTime2 = 0;
    931931  HWND hwndNotify;
    932932  BOOL notFound;
  • trunk/test/zufall.c

    r2 r57  
    88int getRand()
    99{
    10   int zufall;
     10  int zufall = 0;
    1111  DATETIME DT;
    1212  INT  seed, start,  iCheck=0;
Note: See TracChangeset for help on using the changeset viewer.