@@ -3769,6 +3769,7 @@ SWIGINTERN int fz_document_s__select(struct fz_document_s *self,int *liste,int a
3769
3769
pdf_document * pdf = pdf_specifics (gctx , self );
3770
3770
if (!pdf ) {
3771
3771
PyErr_SetString (PyExc_ValueError ,"not a valid pdf document" );
3772
+ free (liste );
3772
3773
return -2 ;
3773
3774
}
3774
3775
globals glo = { 0 };
@@ -4312,8 +4313,11 @@ fz_send_data_base64(fz_context *ctx, fz_output *out, fz_buffer *buffer)
4312
4313
int c = buffer -> data [3 * i ];
4313
4314
int d = buffer -> data [3 * i + 1 ];
4314
4315
int e = buffer -> data [3 * i + 2 ];
4315
- if ((i & 15 ) == 0 )
4316
- fz_printf (ctx , out , "\n" );
4316
+ /*************************************************/
4317
+ /* JSON decoders do not like interspersed "\n" ! */
4318
+ /*************************************************/
4319
+ //if ((i & 15) == 0)
4320
+ // fz_printf(ctx, out, "\n");
4317
4321
fz_printf (ctx , out , "%c%c%c%c" , set [c >>2 ], set [((c & 3 )<<4 )|(d >>4 )], set [((d & 15 )<<2 )|(e >>6 )], set [e & 63 ]);
4318
4322
}
4319
4323
i *= 3 ;
@@ -4400,11 +4404,11 @@ fz_print_stext_page_json(fz_context *ctx, fz_output *out, fz_stext_page *page)
4400
4404
fz_image_block * image = page -> blocks [block_n ].u .image ;
4401
4405
4402
4406
fz_print_rect_json (ctx , out , & (image -> bbox ));
4403
- fz_printf (ctx , out , "\"type \":%d,\"width\":%d,\"height\":%d" ,
4407
+ fz_printf (ctx , out , "\"imgtype \":%d,\"width\":%d,\"height\":%d, " ,
4404
4408
image -> image -> buffer -> params .type ,
4405
4409
image -> image -> w ,
4406
4410
image -> image -> h );
4407
- fz_printf (ctx , out , "\"image\":" );
4411
+ fz_printf (ctx , out , "\"image\":\n " );
4408
4412
if (image -> image -> buffer == NULL ) {
4409
4413
fz_printf (ctx , out , "null" );
4410
4414
} else {
@@ -4958,6 +4962,16 @@ SWIGINTERN PyObject *_wrap_Document__select(PyObject *SWIGUNUSEDPARM(self), PyOb
4958
4962
PyObject * o = PySequence_GetItem (obj1 ,i );
4959
4963
if (PyInt_Check (o )) {
4960
4964
arg2 [i ] = (int ) PyInt_AsLong (o );
4965
+ if (arg2 [i ] < 0 ) {
4966
+ PyErr_SetString (PyExc_ValueError ,"sequence elements must be >= 0" );
4967
+ free (arg2 );
4968
+ return NULL ;
4969
+ }
4970
+ if (arg2 [i ] >= fz_count_pages (gctx , arg1 )) {
4971
+ PyErr_SetString (PyExc_ValueError ,"sequence elements must be < pageCount" );
4972
+ free (arg2 );
4973
+ return NULL ;
4974
+ }
4961
4975
}
4962
4976
else {
4963
4977
PyErr_SetString (PyExc_ValueError ,"sequence elements must be integers" );
0 commit comments