diff options
| author | Andrew Havens <[email protected]> | 2017-12-29 09:26:26 -0800 |
|---|---|---|
| committer | Tom Black <[email protected]> | 2018-01-02 20:35:39 -0800 |
| commit | 50b36b6a8aaf9512a4699734c160fcd82c0c2ea6 (patch) | |
| tree | ad99e261dc37a67128c42434989c94bd4d3742a3 /lib | |
| parent | 038cd2f1a5b99dbc523b8b2b42551e0261e83aa7 (diff) | |
| download | ruby2d-50b36b6a8aaf9512a4699734c160fcd82c0c2ea6.tar.gz ruby2d-50b36b6a8aaf9512a4699734c160fcd82c0c2ea6.zip | |
Check for valid file path to prevent segfault when file does not exist.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ruby2d/sprite.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/ruby2d/sprite.rb b/lib/ruby2d/sprite.rb index e6a6efa..7c66f97 100644 --- a/lib/ruby2d/sprite.rb +++ b/lib/ruby2d/sprite.rb @@ -8,9 +8,11 @@ module Ruby2D def initialize(x, y, path, z=0) - # unless File.exists? path - # raise Error, "Cannot find image file `#{path}`" - # end + unless RUBY_ENGINE == 'opal' + unless File.exists? path + raise Error, "Cannot find sprite image file `#{path}`" + end + end @x, @y, @path = x, y, path @clip_x, @clip_y, @clip_w, @clip_h = 0, 0, 0, 0 |
