From 7e665ed238d01917e40430680b1181c668772756 Mon Sep 17 00:00:00 2001
From: Oleg Bulatov <obulatov@redhat.com>
Date: Wed, 25 Apr 2018 18:19:42 +0200
Subject: [PATCH] Check existance of map before dumping it

---
 src/libkeymap/dump.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/libkeymap/dump.c b/src/libkeymap/dump.c
index c4e2513..8bc5d70 100644
--- a/src/libkeymap/dump.c
+++ b/src/libkeymap/dump.c
@@ -520,8 +520,10 @@ no_shorthands:
 				defs[j] = K(KT_META, KVAL(defs[j - 8]));
 
 			for (j = 0; j < keymapnr; j++) {
-				if ((j >= 16 && buf[j] != K_HOLE) || (j < 16 && buf[j] != defs[j]))
-					goto unexpected;
+				if (lk_map_exists(ctx, j)) {
+					if ((j >= 16 && buf[j] != K_HOLE) || (j < 16 && buf[j] != defs[j]))
+						goto unexpected;
+				}
 			}
 
 			isasexpected = 1;
@@ -577,8 +579,10 @@ no_shorthands:
 				fprintf(fd, "\n");
 
 				for (j = 1; j < keymapnr; j++) {
-					if (buf[j] != buf[0] && !zapped[j]) {
-						print_bind(ctx, fd, buf[j], i, j, numeric);
+					if (lk_map_exists(ctx, j)) {
+						if (buf[j] != buf[0] && !zapped[j]) {
+							print_bind(ctx, fd, buf[j], i, j, numeric);
+						}
 					}
 				}
 			} else {
-- 
2.21.0.windows.1

