Browse Source

random_seed: try other alternatives if reading /dev/random fails

Originally committed as revision 22450 to svn://svn.ffmpeg.org/ffmpeg/trunk
Måns Rullgård 15 years ago
parent
commit
49e9287878
1 changed files with 2 additions and 1 deletions
  1. 2 1
      libavutil/random_seed.c

+ 2 - 1
libavutil/random_seed.c

@@ -31,8 +31,9 @@ uint32_t ff_random_get_seed(void)
     if ((fd = open("/dev/random", O_RDONLY)) == -1)
         fd = open("/dev/urandom", O_RDONLY);
     if (fd != -1){
-        read(fd, &seed, 4);
+        int err = read(fd, &seed, 4);
         close(fd);
+        if (err == 4)
         return seed;
     }
 #ifdef AV_READ_TIME