Check entry is not NULL before dereferencing it.
authorRobin Watts <[email protected]>
Tue, 20 Jul 2021 17:03:25 +0000 (18:03 +0100)
committerRobin Watts <[email protected]>
Tue, 20 Jul 2021 17:06:02 +0000 (18:06 +0100)
In refactoring within prepare_object_for_alteration, I'd moved
a section of code to before we check whether entry is NULL.

source/pdf/pdf-object.c

index b0c1605ad80f9af59944272456296d955fc738b6..e714d11c561028c8c59bc4610b2a1319021822b2 100644 (file)
@@ -1405,14 +1405,16 @@ static void prepare_object_for_alteration(fz_context *ctx, pdf_obj *obj, pdf_obj
        /* We are about to add a fragment. Everything after this in the
         * history must be thrown away. */
        if (entry)
+       {
                discard_journal_entries(ctx, &entry->next);
 
-       for (frag = entry->head; frag != NULL; frag = frag->next)
-               if (frag->obj_num == parent)
-               {
-                       entry = NULL;
-                       break; /* Already stashed this one! */
-               }
+               for (frag = entry->head; frag != NULL; frag = frag->next)
+                       if (frag->obj_num == parent)
+                       {
+                               entry = NULL;
+                               break; /* Already stashed this one! */
+                       }
+       }
 
        /*
                We need to ensure that the containing hierarchy of objects