From 76c6ec8c1afe095a05d96b4e0683876b43eab57b Mon Sep 17 00:00:00 2001
From: Alessandro Pasotti <elpaso@itopen.it>
Date: Wed, 20 Feb 2019 10:10:59 +0100
Subject: [PATCH] Prevent crash when fields are deleted from the vector options
 dialog

---
 src/app/qgsattributesformproperties.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/app/qgsattributesformproperties.cpp b/src/app/qgsattributesformproperties.cpp
index 5770b12007f..5d3c68792ba 100644
--- a/src/app/qgsattributesformproperties.cpp
+++ b/src/app/qgsattributesformproperties.cpp
@@ -277,7 +277,7 @@ void QgsAttributesFormProperties::loadAttributeTypeDialog()
 
 void QgsAttributesFormProperties::storeAttributeTypeDialog()
 {
-  if ( mAttributeTypeDialog->fieldIdx() < 0 )
+  if ( mAttributeTypeDialog->fieldIdx() < 0 || mAttributeTypeDialog->fieldIdx() >= mLayer->fields().count() )
     return;
 
   FieldConfig cfg;