Check results, returned by the TIFFFdOpen() before returning and close
file if TIFFFdOpen() failed as per bug http://bugzilla.remotesensing.org/show_bug.cgi?id=468
This commit is contained in:
parent
9bac33086f
commit
c490e6a948
@ -1,4 +1,4 @@
|
|||||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_unix.c,v 1.4 2002-10-11 14:13:00 dron Exp $ */
|
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_unix.c,v 1.5 2004-01-29 19:54:14 dron Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@ -144,6 +144,7 @@ TIFFOpen(const char* name, const char* mode)
|
|||||||
{
|
{
|
||||||
static const char module[] = "TIFFOpen";
|
static const char module[] = "TIFFOpen";
|
||||||
int m, fd;
|
int m, fd;
|
||||||
|
TIFF* tif;
|
||||||
|
|
||||||
m = _TIFFgetMode(mode, module);
|
m = _TIFFgetMode(mode, module);
|
||||||
if (m == -1)
|
if (m == -1)
|
||||||
@ -167,7 +168,11 @@ TIFFOpen(const char* name, const char* mode)
|
|||||||
TIFFError(module, "%s: Cannot open", name);
|
TIFFError(module, "%s: Cannot open", name);
|
||||||
return ((TIFF *)0);
|
return ((TIFF *)0);
|
||||||
}
|
}
|
||||||
return (TIFFFdOpen(fd, name, mode));
|
|
||||||
|
tif = TIFFFdOpen((int)fd, name, mode);
|
||||||
|
if(!tif)
|
||||||
|
close(fd);
|
||||||
|
return tif;
|
||||||
}
|
}
|
||||||
|
|
||||||
void*
|
void*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_win32.c,v 1.8 2004-01-29 15:39:52 dron Exp $ */
|
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_win32.c,v 1.9 2004-01-29 19:54:14 dron Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1988-1997 Sam Leffler
|
* Copyright (c) 1988-1997 Sam Leffler
|
||||||
@ -154,12 +154,11 @@ TIFFFdOpen(int ifd, const char* name, const char* mode)
|
|||||||
TIFF* tif;
|
TIFF* tif;
|
||||||
BOOL fSuppressMap = (mode[1] == 'u' || (mode[1]!=0 && mode[2] == 'u'));
|
BOOL fSuppressMap = (mode[1] == 'u' || (mode[1]!=0 && mode[2] == 'u'));
|
||||||
|
|
||||||
tif = TIFFClientOpen(name, mode,
|
tif = TIFFClientOpen(name, mode, (thandle_t)ifd,
|
||||||
(thandle_t)ifd,
|
_tiffReadProc, _tiffWriteProc,
|
||||||
_tiffReadProc, _tiffWriteProc,
|
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
|
||||||
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
|
fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
|
||||||
fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
|
fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc);
|
||||||
fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc);
|
|
||||||
if (tif)
|
if (tif)
|
||||||
tif->tif_fd = ifd;
|
tif->tif_fd = ifd;
|
||||||
return (tif);
|
return (tif);
|
||||||
@ -175,6 +174,7 @@ TIFFOpen(const char* name, const char* mode)
|
|||||||
thandle_t fd;
|
thandle_t fd;
|
||||||
int m;
|
int m;
|
||||||
DWORD dwMode;
|
DWORD dwMode;
|
||||||
|
TIFF* tif;
|
||||||
|
|
||||||
m = _TIFFgetMode(mode, module);
|
m = _TIFFgetMode(mode, module);
|
||||||
|
|
||||||
@ -198,14 +198,20 @@ TIFFOpen(const char* name, const char* mode)
|
|||||||
default:
|
default:
|
||||||
return ((TIFF*)0);
|
return ((TIFF*)0);
|
||||||
}
|
}
|
||||||
fd = (thandle_t)CreateFile(name, (m == O_RDONLY) ? GENERIC_READ :
|
fd = (thandle_t)CreateFile(name,
|
||||||
(GENERIC_READ | GENERIC_WRITE), FILE_SHARE_READ, NULL, dwMode,
|
(m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE),
|
||||||
(m == O_RDONLY) ? FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_NORMAL, NULL);
|
FILE_SHARE_READ, NULL, dwMode,
|
||||||
|
(m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
|
||||||
|
NULL);
|
||||||
if (fd == INVALID_HANDLE_VALUE) {
|
if (fd == INVALID_HANDLE_VALUE) {
|
||||||
TIFFError(module, "%s: Cannot open", name);
|
TIFFError(module, "%s: Cannot open", name);
|
||||||
return ((TIFF *)0);
|
return ((TIFF *)0);
|
||||||
}
|
}
|
||||||
return (TIFFFdOpen((int)fd, name, mode));
|
|
||||||
|
tif = TIFFFdOpen((int)fd, name, mode);
|
||||||
|
if(!tif)
|
||||||
|
CloseHandle(fd);
|
||||||
|
return tif;
|
||||||
}
|
}
|
||||||
|
|
||||||
tdata_t
|
tdata_t
|
||||||
|
Loading…
Reference in New Issue
Block a user