shithub: orca

Download patch

ref: e49438378b366fb107c79cbe9766d13dcb53f479
parent: cdd950e455b4bfc62bb59c1ad8fa0fa85015e8f0
author: cancel <cancel@cancel.fm>
date: Tue Jan 28 01:45:26 EST 2020

Add protection against successfully loading a 0x0 file

--- a/tui_main.c
+++ b/tui_main.c
@@ -3451,6 +3451,14 @@
     Field_load_error fle = field_load_file(osoc(t.file_name), &t.ged.field);
     switch (fle) {
     case Field_load_error_ok:
+      if (t.ged.field.height < 1 || t.ged.field.width < 1) {
+        // Opening an empty file or attempting to open a directory can lead us
+        // here.
+        field_deinit(&t.ged.field);
+        qmsg_printf_push("Unusable File", "Not a usable file:\n%s",
+                         (osoc(t.file_name)));
+        break;
+      }
       grid_initialized = true;
       break;
     case Field_load_error_cant_open_file: {