[metadata] Handle condition in ftell, Coverity 1307192 (mono/mono#13862)
authorMiguel de Icaza <miguel@gnome.org>
Sat, 6 Apr 2019 09:35:07 +0000 (05:35 -0400)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Sat, 6 Apr 2019 09:35:07 +0000 (11:35 +0200)
ftell can be a negative value, handle that scenario.

Commit migrated from https://github.com/mono/mono/commit/af4b09ba27f4238c49696b529984167e9baa1a3d

src/mono/mono/metadata/seq-points-data.c

index 7adbfe9..d911258 100644 (file)
@@ -401,6 +401,11 @@ mono_seq_point_data_read (SeqPointData *data, char *path)
 
        fseek(f, 0, SEEK_END);
        fsize = ftell(f);
+       if (fsize == -1){
+               fclose (f);
+               return FALSE;
+       }
+       
        fseek(f, 0, SEEK_SET);
 
        buffer_orig = buffer = (guint8 *)g_malloc (fsize + 1);