Skip to content

Commit 1aba518

Browse files
authored
Merge pull request #4012 from masatake/main--report-errors-in-ftell
main: report errors when calling ftell(3) fails
2 parents 653ca92 + a3493a9 commit 1aba518

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

main/entry.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2325,8 +2325,13 @@ extern void setTagFilePosition (MIOPos *p, bool truncation)
23252325

23262326

23272327
long t0 = 0;
2328-
if (truncation)
2328+
if (truncation) {
23292329
t0 = mio_tell (TagFile.mio);
2330+
if (t0 == -1)
2331+
error (FATAL|PERROR,
2332+
"failed to tell the file position of the tag file (t0)\n");
2333+
}
2334+
23302335

23312336
if (mio_setpos (TagFile.mio, p) == -1)
23322337
error (FATAL|PERROR,
@@ -2335,6 +2340,10 @@ extern void setTagFilePosition (MIOPos *p, bool truncation)
23352340
if (truncation)
23362341
{
23372342
long t1 = mio_tell (TagFile.mio);
2343+
if (t1 == -1)
2344+
error (FATAL|PERROR,
2345+
"failed to tell the file position of the tag file (t0)\n");
2346+
23382347
if (!mio_try_resize (TagFile.mio, (size_t)t1))
23392348
error (FATAL|PERROR,
23402349
"failed to truncate the tag file %ld -> %ld\n", t0, t1);

0 commit comments

Comments
 (0)