texlive[50430] Build/source/texk/web2c/luatexdir: LuaTeX: several

commits+lscarso at tug.org commits+lscarso at tug.org
Sun Mar 17 22:43:59 CET 2019


Revision: 50430
          http://tug.org/svn/texlive?view=revision&revision=50430
Author:   lscarso
Date:     2019-03-17 22:43:59 +0100 (Sun, 17 Mar 2019)
Log Message:
-----------
LuaTeX: several catches for indirect references to non existing objects.

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c
    trunk/Build/source/texk/web2c/luatexdir/lua/lpdfelib.c
    trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h

Modified: trunk/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c	2019-03-17 21:38:40 UTC (rev 50429)
+++ trunk/Build/source/texk/web2c/luatexdir/image/pdftoepdf.c	2019-03-17 21:43:59 UTC (rev 50430)
@@ -552,15 +552,23 @@
     ppref * ref ;
     ppxref * xref = ppdoc_xref (pdf_doc->pdfe);
     for (r = pdf_doc->inObjList; r != NULL;) {
-        ref = ppxref_find (xref, (ppuint) r->objnum);
-        obj = ppref_obj(ref);
-        if (obj->type == PPSTREAM) {
-            pdf_begin_obj(pdf, r->num, OBJSTM_NEVER);
+        if (xref != NULL) {
+            ref = ppxref_find(xref, (ppuint) r->objnum);
+            if (ref != NULL) {
+                obj = ppref_obj(ref);
+                if (obj->type == PPSTREAM) {
+                    pdf_begin_obj(pdf, r->num, OBJSTM_NEVER);
+                } else {
+                    pdf_begin_obj(pdf, r->num, 2);
+                }
+                copyObject(pdf, pdf_doc, obj);
+                pdf_end_obj(pdf);
+            } else {
+                formatted_warning("pdf inclusion","ignoring missing object %i, case 1\n",(int) r->objnum);
+            }
         } else {
-            pdf_begin_obj(pdf, r->num, 2);
+            formatted_warning("pdf inclusion","ignoring missing object %i, case 2\n",(int) r->objnum);
         }
-        copyObject(pdf, pdf_doc, obj);
-        pdf_end_obj(pdf);
         n = r->next;
         free(r);
         r = n;
@@ -995,19 +1003,25 @@
     } else {
         PdfDocument * pdf_doc = refPdfDocument(img_filepath(idict), FE_FAIL, img_userpassword(idict), img_ownerpassword(idict));
         ppdoc * pdfe = pdf_doc->pdfe;
-        ppref * ref = ppxref_find(ppdoc_xref(pdfe), (ppuint) n);
-        if (ref != NULL) {
-            ppobj *obj;
-            num = pdf->obj_count++;
-            obj = ppref_obj(ref);
-            if (obj->type == PPSTREAM) {
-                pdf_begin_obj(pdf, num, OBJSTM_NEVER);
+        if (ppdoc_xref(pdfe)) {
+            ppref * ref = ppxref_find(ppdoc_xref(pdfe), (ppuint) n);
+            if (ref != NULL) {
+                ppobj *obj;
+                num = pdf->obj_count++;
+                obj = ppref_obj(ref);
+                if (obj->type == PPSTREAM) {
+                    pdf_begin_obj(pdf, num, OBJSTM_NEVER);
+                } else {
+                    pdf_begin_obj(pdf, num, 2);
+                }
+                copyObject(pdf, pdf_doc, obj);
+                pdf_end_obj(pdf);
+                writeRefs(pdf, pdf_doc);
             } else {
-                pdf_begin_obj(pdf, num, 2);
+                formatted_warning("pdf inclusion","ignoring missing image %i, case 1\n",(int) n);
             }
-            copyObject(pdf, pdf_doc, obj);
-            pdf_end_obj(pdf);
-            writeRefs(pdf, pdf_doc);
+        } else {
+            formatted_warning("pdf inclusion","ignoring missing image %i, case 2\n",(int) n);
         }
         if (! img_keepopen(idict)) {
             unrefPdfDocument(img_filepath(idict));

Modified: trunk/Build/source/texk/web2c/luatexdir/lua/lpdfelib.c
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/lua/lpdfelib.c	2019-03-17 21:38:40 UTC (rev 50429)
+++ trunk/Build/source/texk/web2c/luatexdir/lua/lpdfelib.c	2019-03-17 21:43:59 UTC (rev 50430)
@@ -367,7 +367,7 @@
 
 static int pushreference(lua_State * L, ppref * reference)
 {
-    if (reference != NULL) {
+    if (reference != NULL && reference->number != 0) {
         pdfe_push_reference;
         lua_pushinteger(L,reference->number);
         return 2;
@@ -502,8 +502,10 @@
         int index = luaL_checkint(L, 2) - 1;
         if (index < a->array->size) {
             ppobj *object = pparray_at(a->array,index);
-            lua_pushinteger(L,(int) object->type);
-            return 1 + pushvalue(L,object);
+            if (object != NULL) {
+                lua_pushinteger(L,(int) object->type);
+                return 1 + pushvalue(L,object);
+            }
         }
     }
     return 0;
@@ -524,10 +526,12 @@
             int index = luaL_checkint(L, 2) - 1;
             if (index < d->dictionary->size) {
                 ppobj *object = ppdict_at(d->dictionary,index);
-                ppname key = ppdict_key(d->dictionary,index);
-                lua_pushstring(L,(const char *) key);
-                lua_pushinteger(L,(int) object->type);
-                return 2 + pushvalue(L,object);
+                if (object != NULL) {
+                    ppname key = ppdict_key(d->dictionary,index);
+                    lua_pushstring(L,(const char *) key);
+                    lua_pushinteger(L,(int) object->type);
+                    return 2 + pushvalue(L,object);
+                }
             }
         }
     }
@@ -550,10 +554,12 @@
             int index = luaL_checkint(L, 2) - 1;
             if (index < d->size) {
                 ppobj *object = ppdict_at(d,index);
-                ppname key = ppdict_key(d,index);
-                lua_pushstring(L,(const char *) key);
-                lua_pushinteger(L,(int) object->type);
-                return 2 + pushvalue(L,object);
+                if (object != NULL) {
+                    ppname key = ppdict_key(d,index);
+                    lua_pushstring(L,(const char *) key);
+                    lua_pushinteger(L,(int) object->type);
+                    return 2 + pushvalue(L,object);
+                }
             }
         }
     }
@@ -622,14 +628,17 @@
     if (a != NULL) {
         int flat = lua_isboolean(L,2);
         int i = 0;
+        int j = 0;
         lua_createtable(L,i,0);
         /* table */
         for (i=0;i<a->array->size;i++) {
             ppobj *object = pparray_at(a->array,i);
-            pdfelib_totable(L,object,flat);
-            /* table { type, [value], [extra], [more] } */
-            lua_rawseti(L,-2,i+1);
-            /* table[i] = { type, [value], [extra], [more] } */
+            if (object != NULL) {
+                pdfelib_totable(L,object,flat);
+                /* table { type, [value], [extra], [more] } */
+                lua_rawseti(L,-2,++j);
+                /* table[i] = { type, [value], [extra], [more] } */
+            }
         }
         return 1;
     }
@@ -646,13 +655,15 @@
         /* table */
         for (i=0;i<d->dictionary->size;i++) {
             ppobj *object = ppdict_at(d->dictionary,i);
-            ppname key = ppdict_key(d->dictionary,i);
-            lua_pushstring(L,(const char *) key);
-            /* table key */
-            pdfelib_totable(L,object,flat);
-            /* table key { type, [value], [extra], [more] } */
-            lua_rawset(L,-3);
-            /* table[key] = { type, [value], [extra] } */
+            if (object != NULL) {
+                ppname key = ppdict_key(d->dictionary,i);
+                lua_pushstring(L,(const char *) key);
+                /* table key */
+                pdfelib_totable(L,object,flat);
+                /* table key { type, [value], [extra], [more] } */
+                lua_rawset(L,-3);
+                /* table[key] = { type, [value], [extra] } */
+            }
         }
         return 1;
     }
@@ -676,22 +687,25 @@
         ppdoc *d = p->document;
         ppref *r = NULL;
         int i = 0;
+        int j = 0;
         lua_createtable(L,ppdoc_page_count(d),0);
         /* pages[1..n] */
         for (r = ppdoc_first_page(d), i = 1; r != NULL; r = ppdoc_next_page(d), ++i) {
             lua_createtable(L,3,0);
-            pushdictionary(L,ppref_obj(r)->dict);
-            /* table dictionary n */
-            lua_rawseti(L,-3,2);
-            /* table dictionary */
-            lua_rawseti(L,-2,1);
-            /* table */
-            lua_pushinteger(L,r->number);
-            /* table reference */
-            lua_rawseti(L,-2,3);
-            /* table */
-            lua_rawseti(L,-2,i);
-            /* pages[i] = { dictionary, size, objnum } */
+            if (ppref_obj(r) != NULL) {
+                pushdictionary(L,ppref_obj(r)->dict);
+                /* table dictionary n */
+                lua_rawseti(L,-3,2);
+                /* table dictionary */
+                lua_rawseti(L,-2,1);
+                /* table */
+                lua_pushinteger(L,r->number);
+                /* table reference */
+                lua_rawseti(L,-2,3);
+                /* table */
+                lua_rawseti(L,-2,++j);
+                /* pages[i] = { dictionary, size, objnum } */
+            }
         }
         return 1;
     }
@@ -1158,10 +1172,15 @@
 static int pdfelib_getfromreference(lua_State * L)
 {
     pdfe_reference *r = check_isreference(L, 1);
-    if (r != NULL) {
-        ppobj *o = ppref_obj(ppxref_find(r->xref, (ppuint) r->onum));
-        lua_pushinteger(L,o->type);
-        return 1 + pushvalue(L,o);
+    if (r != NULL && r->xref != NULL) {
+        ppref *rr = ppxref_find(r->xref, (ppuint) r->onum);
+        if (rr != NULL) {
+            ppobj *o = ppref_obj(rr);
+            if (o != NULL) {
+                lua_pushinteger(L,o->type);
+                return 1 + pushvalue(L,o);
+            }
+        }
     }
     return 0;
 }
@@ -1213,8 +1232,8 @@
 */
 
 # define pdfelib_get_indirect_o(p) \
-    ppref *r = ppxref_find(((pdfe_reference *) p)->xref, (ppuint) (((pdfe_reference *) p)->onum)); \
-    ppobj *o = ppref_obj(r);                                \
+    ppref *r = (((pdfe_reference *) p)->xref != NULL) ? ppxref_find(((pdfe_reference *) p)->xref, (ppuint) (((pdfe_reference *) p)->onum)) : NULL; \
+    ppobj *o = (r != NULL) ? ppref_obj(r) : NULL; \
 
 # define pdfelib_get_value_direct(get_d,get_a) do {                      \
     int t = lua_type(L,2);                                              \

Modified: trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h
===================================================================
--- trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h	2019-03-17 21:38:40 UTC (rev 50429)
+++ trunk/Build/source/texk/web2c/luatexdir/luatex_svnversion.h	2019-03-17 21:43:59 UTC (rev 50430)
@@ -1 +1 @@
-#define luatex_svn_revision 7116
+#define luatex_svn_revision 7119



More information about the tex-live-commits mailing list