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
|
||||
@ -144,6 +144,7 @@ TIFFOpen(const char* name, const char* mode)
|
||||
{
|
||||
static const char module[] = "TIFFOpen";
|
||||
int m, fd;
|
||||
TIFF* tif;
|
||||
|
||||
m = _TIFFgetMode(mode, module);
|
||||
if (m == -1)
|
||||
@ -167,7 +168,11 @@ TIFFOpen(const char* name, const char* mode)
|
||||
TIFFError(module, "%s: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
return (TIFFFdOpen(fd, name, mode));
|
||||
|
||||
tif = TIFFFdOpen((int)fd, name, mode);
|
||||
if(!tif)
|
||||
close(fd);
|
||||
return tif;
|
||||
}
|
||||
|
||||
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
|
||||
@ -154,8 +154,7 @@ TIFFFdOpen(int ifd, const char* name, const char* mode)
|
||||
TIFF* tif;
|
||||
BOOL fSuppressMap = (mode[1] == 'u' || (mode[1]!=0 && mode[2] == 'u'));
|
||||
|
||||
tif = TIFFClientOpen(name, mode,
|
||||
(thandle_t)ifd,
|
||||
tif = TIFFClientOpen(name, mode, (thandle_t)ifd,
|
||||
_tiffReadProc, _tiffWriteProc,
|
||||
_tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
|
||||
fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
|
||||
@ -175,6 +174,7 @@ TIFFOpen(const char* name, const char* mode)
|
||||
thandle_t fd;
|
||||
int m;
|
||||
DWORD dwMode;
|
||||
TIFF* tif;
|
||||
|
||||
m = _TIFFgetMode(mode, module);
|
||||
|
||||
@ -198,14 +198,20 @@ TIFFOpen(const char* name, const char* mode)
|
||||
default:
|
||||
return ((TIFF*)0);
|
||||
}
|
||||
fd = (thandle_t)CreateFile(name, (m == O_RDONLY) ? GENERIC_READ :
|
||||
(GENERIC_READ | GENERIC_WRITE), FILE_SHARE_READ, NULL, dwMode,
|
||||
(m == O_RDONLY) ? FILE_ATTRIBUTE_READONLY : FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
fd = (thandle_t)CreateFile(name,
|
||||
(m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE),
|
||||
FILE_SHARE_READ, NULL, dwMode,
|
||||
(m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
if (fd == INVALID_HANDLE_VALUE) {
|
||||
TIFFError(module, "%s: Cannot open", name);
|
||||
return ((TIFF *)0);
|
||||
}
|
||||
return (TIFFFdOpen((int)fd, name, mode));
|
||||
|
||||
tif = TIFFFdOpen((int)fd, name, mode);
|
||||
if(!tif)
|
||||
CloseHandle(fd);
|
||||
return tif;
|
||||
}
|
||||
|
||||
tdata_t
|
||||
|
Loading…
Reference in New Issue
Block a user