diff --git a/pdf/pdf_colour.c b/pdf/pdf_colour.c
index ebd95e1..fd873f9 100644
--- a/pdf/pdf_colour.c
+++ b/pdf/pdf_colour.c
@@ -2092,9 +2092,13 @@ pdfi_create_indexed(pdf_context *ctx, pdf_array *color_array, int index,
     if (code < 0)
         goto exit;
 
-    (void)pcs_base->type->install_cspace(pcs_base, ctx->pgs);
-
     base_type = gs_color_space_get_index(pcs_base);
+    if (base_type == gs_color_space_index_Pattern || base_type == gs_color_space_index_Indexed) {
+        code = gs_note_error(gs_error_typecheck);
+        goto exit;
+    }
+
+    (void)pcs_base->type->install_cspace(pcs_base, ctx->pgs);
 
     code = pdfi_array_get(ctx, color_array, index + 3, &lookup);
     if (code < 0)
