Repository: godot
Issue: Division by zero in rasterizer_canvas_gles3.cpp
Labels: bug,topic:core

**Godot version:**
3.2 beta 1
**OS/device including version:**
Ubuntu 19.10
**Issue description:**

```
drivers/gles3/rasterizer_canvas_gles3.cpp:998:52: runtime error: division by zero
drivers/gles3/rasterizer_canvas_gles3.cpp:998:30: runtime error: division by zero
drivers/gles3/rasterizer_canvas_gles3.cpp:824:52: runtime error: division by zero
drivers/gles3/rasterizer_canvas_gles3.cpp:824:30: runtime error: division by zero
```

One of possible solutions
```
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index edffe852a2..f9acb184d3 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -820,7 +820,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
 
                                RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(mesh->texture, mesh->normal_map);
 
-                               if (texture) {
+                               if (texture && texture->width != 0 && texture->height != 0) {
                                        Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
                                        state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
                                }
@@ -871,7 +871,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
                                state.using_texture_rect = true;
                                _set_texture_rect_mode(false);
 
-                               if (texture) {
+                               if (texture && texture->width != 0 && texture->height != 0) {
                                        Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
                                        state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
                                }
@@ -994,7 +994,7 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
 
                                RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(particles_cmd->texture, particles_cmd->normal_map);
 
-                               if (texture) {
+                               if (texture && texture->width != 0 && texture->height != 0) {
                                        Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
                                        state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
                                } else {

```
**Steps to reproduce:**
To get this error try to compile Godot with ubsan sanitizer(GCC or LLVM) or compile Godot from this branch(find more errors but tgis needs LLVM 9 or GCC 9) - https://github.com/qarmin/godot/tree/bb

1. Read Project README - https://github.com/qarmin/The-worst-Godot-test-project#the-worst-godot-test-project
2. Run Project


**Minimal reproduction project:**
https://github.com/qarmin/The-worst-Godot-test-project/archive/60944c7930279db20747b8d1835e1687188a10ab.zip