static int
OJPEGReadHeaderInfoSecTablesQTable(TIFF* tif)
{
	static const char module[]="OJPEGReadHeaderInfoSecTablesQTable";
	OJPEGState* sp=(OJPEGState*)tif->tif_data;
	uint8 m;
	uint8 n;
	uint32 oa;
	uint8* ob;
	uint32 p;
	if (sp->qtable_offset[0]==0)
	{
		TIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables");
		return(0);
	}
	sp->in_buffer_file_pos_log=0;
	for (m=0; m<sp->samples_per_pixel; m++)
	{
		if ((sp->qtable_offset[m]!=0) && ((m==0) || (sp->qtable_offset[m]!=sp->qtable_offset[m-1])))
		{
			for (n=0; n<m-1; n++)
			{
				if (sp->qtable_offset[m]==sp->qtable_offset[n])
				{
					TIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegQTables tag value");
					return(0);
				}
			}
			oa=sizeof(uint32)+69;
			ob=_TIFFmalloc(oa);
			if (ob==0)
			{
				TIFFErrorExt(tif->tif_clientdata,module,"Out of memory");
				return(0);
			}
			*(uint32*)ob=oa;
			ob[sizeof(uint32)]=255;
			ob[sizeof(uint32)+1]=JPEG_MARKER_DQT;
			ob[sizeof(uint32)+2]=0;
			ob[sizeof(uint32)+3]=67;
			ob[sizeof(uint32)+4]=m;
			TIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET);
			p=TIFFReadFile(tif,&ob[sizeof(uint32)+5],64);
			if (p!=64)
				return(0);
			sp->qtable[m]=ob;
			sp->sof_tq[m]=m;
		}
		else
			sp->sof_tq[m]=sp->sof_tq[m-1];
	}
	return(1);
}
['static int\nOJPEGReadHeaderInfoSecTablesQTable(TIFF* tif)\n{\n\tstatic const char module[]="OJPEGReadHeaderInfoSecTablesQTable";\n\tOJPEGState* sp=(OJPEGState*)tif->tif_data;\n\tuint8 m;\n\tuint8 n;\n\tuint32 oa;\n\tuint8* ob;\n\tuint32 p;\n\tif (sp->qtable_offset[0]==0)\n\t{\n\t\tTIFFErrorExt(tif->tif_clientdata,module,"Missing JPEG tables");\n\t\treturn(0);\n\t}\n\tsp->in_buffer_file_pos_log=0;\n\tfor (m=0; m<sp->samples_per_pixel; m++)\n\t{\n\t\tif ((sp->qtable_offset[m]!=0) && ((m==0) || (sp->qtable_offset[m]!=sp->qtable_offset[m-1])))\n\t\t{\n\t\t\tfor (n=0; n<m-1; n++)\n\t\t\t{\n\t\t\t\tif (sp->qtable_offset[m]==sp->qtable_offset[n])\n\t\t\t\t{\n\t\t\t\t\tTIFFErrorExt(tif->tif_clientdata,module,"Corrupt JpegQTables tag value");\n\t\t\t\t\treturn(0);\n\t\t\t\t}\n\t\t\t}\n\t\t\toa=sizeof(uint32)+69;\n\t\t\tob=_TIFFmalloc(oa);\n\t\t\tif (ob==0)\n\t\t\t{\n\t\t\t\tTIFFErrorExt(tif->tif_clientdata,module,"Out of memory");\n\t\t\t\treturn(0);\n\t\t\t}\n\t\t\t*(uint32*)ob=oa;\n\t\t\tob[sizeof(uint32)]=255;\n\t\t\tob[sizeof(uint32)+1]=JPEG_MARKER_DQT;\n\t\t\tob[sizeof(uint32)+2]=0;\n\t\t\tob[sizeof(uint32)+3]=67;\n\t\t\tob[sizeof(uint32)+4]=m;\n\t\t\tTIFFSeekFile(tif,sp->qtable_offset[m],SEEK_SET);\n\t\t\tp=TIFFReadFile(tif,&ob[sizeof(uint32)+5],64);\n\t\t\tif (p!=64)\n\t\t\t\treturn(0);\n\t\t\tsp->qtable[m]=ob;\n\t\t\tsp->sof_tq[m]=m;\n\t\t}\n\t\telse\n\t\t\tsp->sof_tq[m]=sp->sof_tq[m-1];\n\t}\n\treturn(1);\n}', 'void*\n_TIFFmalloc(tmsize_t s)\n{\n\treturn (malloc((size_t) s));\n}']