Changeset 351 for trunk/dll


Ignore:
Timestamp:
Jul 26, 2006, 9:03:27 PM (19 years ago)
Author:
root
Message:

Check more run time errors

Location:
trunk/dll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/dll/literal.c

    r298 r351  
    1414  01 Aug 04 SHL Rework fixup to avoid overflows
    1515  16 Jun 06 SHL liternal: comments
     16  22 Jul 06 SHL Check more run time errors
    1617
    1718***********************************************************************/
     
    1920#define INCL_OS2
    2021#define INCL_WIN
    21 
    2222#include <os2.h>
     23
    2324#include <ctype.h>
    2425#include <stdlib.h>
    2526#include <stdio.h>
    2627#include <string.h>
     28
    2729#include "fm3dll.h"
     30
     31static PSZ pszSrcFile = __FILE__;
    2832
    2933static INT index(const CHAR *s,const CHAR c);
     
    8892    return 0;
    8993  cBufBytes = strlen(pszBuf) + 1;
    90   pszWork = pszOut = malloc(cBufBytes + 1);
     94  pszWork = pszOut = xmalloc(cBufBytes + 1,pszSrcFile,__LINE__);
    9195
    9296  iBuf = 0;                             /* set index to first character */
  • trunk/dll/loadbmp.c

    r2 r351  
     1
     2/***********************************************************************
     3
     4  $Id$
     5
     6  Load bitmaps
     7
     8  Copyright (c) 1993-98 M. Kimes
     9  Copyright (c) 2006 Steven H.Levine
     10
     11  22 Jul 06 SHL Check more run time errors
     12
     13***********************************************************************/
     14
    115#define INCL_DOS
    216#define INCL_WIN
    317#define INCL_GPI
    4 
    518#include <os2.h>
     19
    620#include <stdlib.h>
    721#include <stdio.h>
    822#include <string.h>
    923#include <share.h>
     24
    1025#include "fm3dll.h"
    1126
     27static PSZ pszSrcFile = __FILE__;
     28
    1229#pragma alloc_text(LOADBITMAP,LoadBitmapFromFile,LoadBitmapFromFileNum)
    1330
    1431
    15 HBITMAP LoadBitmapFromFileNum (USHORT id) {
    16 
    17   char s[CCHMAXPATH];
     32HBITMAP LoadBitmapFromFileNum (USHORT id)
     33{
     34    char s[CCHMAXPATH];
    1835
    1936  save_dir2(s);
     
    2340
    2441
    25 HBITMAP LoadBitmapFromFile (CHAR *pszFileName) {
    26 
     42HBITMAP LoadBitmapFromFile (CHAR *pszFileName)
     43{
    2744  HBITMAP                 hBmp = (HBITMAP)0;
    2845  FILE                   *File;
     
    3047  USHORT                  usType = 0;           // #@!!! compiler warnings
    3148  PBITMAPARRAYFILEHEADER2 pbafh2 = NULL;        // (MAM) chng init values to NULL instead of ptr to 0
    32   PBITMAPFILEHEADER2      pbfh2  = NULL;                       
    33   PBITMAPINFOHEADER2      pbih2  = NULL;                       
    34   PBITMAPINFO2            pbmi2  = NULL;                       
    35   PBITMAPARRAYFILEHEADER  pbafh  = NULL;                       
    36   PBITMAPFILEHEADER       pbfh   = NULL;                       
    37   PBITMAPINFOHEADER       pbih   = NULL;                       
     49  PBITMAPFILEHEADER2      pbfh2  = NULL;
     50  PBITMAPINFOHEADER2      pbih2  = NULL;
     51  PBITMAPINFO2            pbmi2  = NULL;
     52  PBITMAPARRAYFILEHEADER  pbafh  = NULL;
     53  PBITMAPFILEHEADER       pbfh   = NULL;
     54  PBITMAPINFOHEADER       pbih   = NULL;
    3855  BOOL                    f2;        // format 1.x or 2.x
    3956  ULONG                   ulOffset;
     
    5673  /* Next read the bitmap info header........................................*/
    5774  // we allocate enough to hold a complete bitmap array file header
    58   pbafh2 = (PBITMAPARRAYFILEHEADER2)malloc(sizeof(*pbafh2) +
    59                                              256 * sizeof(RGB2));
     75  pbafh2 = xmalloc(sizeof(*pbafh2) + 256 * sizeof(RGB2),pszSrcFile,__LINE__);
    6076  if(!pbafh2)
    6177    goto ExitLoadBMP;
     
    248264    ulDataSize = (((pbmi2->cBitCount * pbmi2->cx) + 31) / 32) * 4 *
    249265                  pbmi2->cy * pbmi2->cPlanes;
    250   pData = (PBYTE)malloc(ulDataSize);
     266  pData = xmalloc(ulDataSize,pszSrcFile,__LINE__);
    251267  if(!pData)
    252268    goto ExitLoadBMP;
     
    263279
    264280ExitLoadBMP:
    265   if(pData)
    266     free(pData);
    267   if(pbafh2)
    268     free(pbafh2);
     281
     282  xfree(pData);
     283  xfree(pbafh2);
    269284  fclose(File);
    270285  WinReleasePS(hPS);
    271   return(hBmp);
     286  return hBmp;
    272287}
    273288
Note: See TracChangeset for help on using the changeset viewer.