IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8777


Ignore:
Timestamp:
Sep 7, 2006, 4:59:29 PM (20 years ago)
Author:
jhoblitt
Message:

check mmap()s return value

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psMetadataConfig.c

    r8774 r8777  
    1010*  @author Eric Van Alst, MHPCC
    1111*
    12 *  @version $Revision: 1.80 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2006-09-08 02:13:20 $
     12*  @version $Revision: 1.81 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2006-09-08 02:59:29 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    11721172    // XXX yes, mmap is evil
    11731173    void *file = mmap(0, (size_t)buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
     1174    if (file == MAP_FAILED) {
     1175        psError(PS_ERR_IO, true, _("failed to mmap() file %s"), filename);
     1176        if (close(fd) != 0) {
     1177            // XXX really should return strerror() here
     1178            psError(PS_ERR_IO, true, _("Failed to close file '%s'."), filename);
     1179            return NULL;
     1180        }
     1181        return NULL;
     1182    }
    11741183
    11751184    md = psMetadataConfigParse(md, nFail, (char *)file, overwrite);
Note: See TracChangeset for help on using the changeset viewer.