diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module
index ae20c49..9b544ae 100644
--- a/core/modules/editor/editor.module
+++ b/core/modules/editor/editor.module
@@ -409,12 +409,13 @@ function editor_entity_revision_delete(EntityInterface $entity) {
  */
 function _editor_record_file_usage(array $uuids, EntityInterface $entity) {
   foreach ($uuids as $uuid) {
-    $file = entity_load_by_uuid('file', $uuid);
-    if ($file->status !== FILE_STATUS_PERMANENT) {
-      $file->status = FILE_STATUS_PERMANENT;
-      $file->save();
+    if ($file = entity_load_by_uuid('file', $uuid)) {
+      if ($file->status !== FILE_STATUS_PERMANENT) {
+        $file->status = FILE_STATUS_PERMANENT;
+        $file->save();
+      }
+      \Drupal::service('file.usage')->add($file, 'editor', $entity->getEntityTypeId(), $entity->id());
     }
-    \Drupal::service('file.usage')->add($file, 'editor', $entity->getEntityTypeId(), $entity->id());
   }
 }
 
@@ -433,8 +434,9 @@ function _editor_record_file_usage(array $uuids, EntityInterface $entity) {
  */
 function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count) {
   foreach ($uuids as $uuid) {
-    $file = entity_load_by_uuid('file', $uuid);
-    \Drupal::service('file.usage')->delete($file, 'editor', $entity->getEntityTypeId(), $entity->id(), $count);
+    if ($file = entity_load_by_uuid('file', $uuid)) {
+      \Drupal::service('file.usage')->delete($file, 'editor', $entity->getEntityTypeId(), $entity->id(), $count);
+    }
   }
 }
 
diff --git a/core/modules/editor/src/Tests/EditorFileUsageTest.php b/core/modules/editor/src/Tests/EditorFileUsageTest.php
index 7c0ba3b..07fb6f7 100644
--- a/core/modules/editor/src/Tests/EditorFileUsageTest.php
+++ b/core/modules/editor/src/Tests/EditorFileUsageTest.php
@@ -103,6 +103,16 @@ public function testEditorEntityHooks() {
     entity_revision_delete('node', $second_revision_id);
     $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), $file_usage->listUsage($image), 'The image has 2 usages.');
 
+    // Test _editor_record_file_usage()'s handling of invalid data- attributes.
+    $node->get('body')->first()->get('value')->setValue('<img src="awesome-llama.jpg" data-editor-file-uuid="" /><img src="awesome-llama.jpg" data-editor-file-uuid="f5524b82-20b3-4d8f-bceb-5034e37db5f5" />');
+    $node->save();
+    $this->assertIdentical(array('editor' => array('node' => array(1 => '1'))), $file_usage->listUsage($image), 'The image has 1 usages.');
+
+    // Test _editor_delete_file_usage()'s handling of invalid data- attributes.
+    $node->get('body')->first()->get('value')->setValue($original_value);
+    $node->save();
+    $this->assertIdentical(array('editor' => array('node' => array(1 => '2'))), $file_usage->listUsage($image), 'The image has 2 usages.');
+
     // Test editor_entity_delete().
     $node->delete();
     $this->assertIdentical(array(), $file_usage->listUsage($image), 'The image has zero usages again.');
