ippFloodFill crashes because of wrong buffer

ippFloodFill crashes because of wrong buffer

Hello,

exactly for this image there is an overflow. The buffer is to small. It does not matter if the whole image is scanned or only 29x29. The buffer is overwritten.

Does anyone know a solution?

Best regard!

void ExecuteFloodFillGrad()
{
  const int width = 29;
  const int height = 29;
  const int stepFloat = 32;
  const int step = stepFloat*sizeof(Ipp32f);

		Ipp32f image[stepFloat*height] = {
			-0.041359305f, -0.040551849f, -0.039700896f, -0.038801193f, -0.037854474f, -0.036893703f, -0.035940997f, -0.034996118f, -0.034058873f, -0.033125922f, -0.032198206f, -0.031274345f, -0.030351648f, -0.029429829f, -0.028508564f, -0.027586684f, -0.026663359f, -0.025735574f, -0.024801414f, -0.027460925f, -0.026567634f, -0.025669908f, -0.024767900f, -0.023866726f, -0.022970574f, -0.022076001f, -0.021180894f, -0.020286271f, -0.019390738f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.041799415f, -0.040994138f, -0.040141661f, -0.039242487f, -0.038292460f, -0.037327528f, -0.036370717f, -0.035423342f, -0.034481280f, -0.033546295f, -0.032614194f, -0.031688336f, -0.030762870f, -0.029841159f, -0.028918007f, -0.027997596f, -0.027071640f, -0.026144236f, -0.025211867f, -0.027869157f, -0.026975738f, -0.026081143f, -0.025179781f, -0.024281939f, -0.023385651f, -0.022492629f, -0.021597851f, -0.020707674f, -0.019812819f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.042244311f, -0.041439246f, -0.040587161f, -0.039687391f, -0.038734592f, -0.037764940f, -0.036803838f, -0.035851441f, -0.034905568f, -0.033966787f, -0.033031702f, -0.032103289f, -0.031176910f, -0.030251876f, -0.029329112f, -0.028405424f, -0.027481673f, -0.026554044f, -0.025622411f, -0.028275793f, -0.027385123f, -0.026490301f, -0.025590317f, -0.024693279f, -0.023799501f, -0.022907382f, -0.022013256f, -0.021125857f, -0.020235062f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.042694889f, -0.041889694f, -0.041038942f, -0.040137414f, -0.039183147f, -0.038210835f, -0.037243251f, -0.036287144f, -0.035337999f, -0.034395196f, -0.033457316f, -0.032525331f, -0.031597015f, -0.030670485f, -0.029745452f, -0.028822016f, -0.027896497f, -0.026968427f, -0.026037738f, -0.026896473f, -0.027798757f, -0.026906194f, -0.026008200f, -0.025112344f, -0.024219094f, -0.023328252f, -0.022437630f, -0.021550965f, -0.020661617f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.043148592f, -0.042345498f, -0.041493021f, -0.040591247f, -0.039635263f, -0.038659472f, -0.037688714f, -0.036725979f, -0.035772994f, -0.034825597f, -0.033885539f, -0.032950614f, -0.032019388f, -0.031089969f, -0.030164545f, -0.029238699f, -0.028314168f, -0.027385920f, -0.026455147f, -0.025520429f, -0.028215265f, -0.027323440f, -0.026427694f, -0.025531026f, -0.024639560f, -0.023750352f, -0.022862127f, -0.021976562f, -0.021090563f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.043600090f, -0.042796899f, -0.041945782f, -0.041043114f, -0.040083509f, -0.039106201f, -0.038130593f, -0.037163854f, -0.036204148f, -0.035254806f, -0.034310859f, -0.033373278f, -0.032438606f, -0.031508628f, -0.030580632f, -0.029653905f, -0.028726444f, -0.027798690f, -0.026868511f, -0.025934940f, -0.028625757f, -0.027734889f, -0.026841603f, -0.025947213f, -0.025054105f, -0.024166826f, -0.023280330f, -0.022397183f, -0.021511339f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.044056710f, -0.043253947f, -0.042402506f, -0.041497547f, -0.040538318f, -0.039557509f, -0.038574893f, -0.037604328f, -0.036640871f, -0.035686634f, -0.034739021f, -0.033797801f, -0.032860730f, -0.031927973f, -0.030998468f, -0.030069444f, -0.029141817f, -0.028213132f, -0.027282942f, -0.026349908f, -0.029038509f, -0.028150229f, -0.027256045f, -0.026361464f, -0.025472213f, -0.024584871f, -0.023698555f, -0.022817720f, -0.021933461f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.044514723f, -0.043712448f, -0.042861395f, -0.041956007f, -0.040992301f, -0.040010717f, -0.039025802f, -0.038048889f, -0.037081096f, -0.036121782f, -0.035171524f, -0.034226902f, -0.033286870f, -0.032351185f, -0.031419180f, -0.030488946f, -0.029560160f, -0.028631227f, -0.027700879f, -0.026768655f, -0.029454703f, -0.028566146f, -0.027674062f, -0.026779654f, -0.025889454f, -0.025003811f, -0.024120955f, -0.023241870f, -0.022358114f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.044975843f, -0.044174772f, -0.043323617f, -0.042415321f, -0.041450761f, -0.040466398f, -0.039479528f, -0.038496841f, -0.037523728f, -0.036560737f, -0.035605654f, -0.034656636f, -0.033715487f, -0.032777101f, -0.031841613f, -0.030909987f, -0.029979447f, -0.029050075f, -0.028119378f, -0.027186455f, -0.029870428f, -0.028982284f, -0.028090714f, -0.027196763f, -0.026307335f, -0.025423249f, -0.024539825f, -0.023660805f, -0.022780357f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.045447979f, -0.044645637f, -0.043794811f, -0.042886533f, -0.041918468f, -0.040931985f, -0.039942227f, -0.038953856f, -0.037976738f, -0.037007824f, -0.036050469f, -0.035095628f, -0.034150284f, -0.033209782f, -0.032273058f, -0.031338178f, -0.030407773f, -0.029475663f, -0.028545270f, -0.027611895f, -0.030293945f, -0.029404689f, -0.028515251f, -0.027621195f, -0.026732901f, -0.025847889f, -0.024967659f, -0.024088649f, -0.023210445f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.045919187f, -0.045118805f, -0.044266216f, -0.043357026f, -0.042387597f, -0.041396633f, -0.040404815f, -0.039414093f, -0.038430385f, -0.037456937f, -0.036495108f, -0.035537459f, -0.034586519f, -0.033643719f, -0.032704335f, -0.031767659f, -0.030835528f, -0.029902589f, -0.028971015f, -0.028037407f, -0.028909868f, -0.029828370f, -0.028939053f, -0.028045695f, -0.027157433f, -0.026274197f, -0.025394611f, -0.024516942f, -0.023638848f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.046403028f, -0.045602452f, -0.044749685f, -0.043838020f, -0.042866852f, -0.041873198f, -0.040878363f, -0.039885540f, -0.038896132f, -0.037918676f, -0.036949720f, -0.035988603f, -0.035035893f, -0.034088127f, -0.033145037f, -0.032207623f, -0.031271882f, -0.030338336f, -0.029405825f, -0.028471809f, -0.027536253f, -0.030260468f, -0.029369731f, -0.028480545f, -0.027591316f, -0.026709298f, -0.025828350f, -0.024952425f, -0.024075883f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.046890851f, -0.046090707f, -0.045237664f, -0.044324689f, -0.043350741f, -0.042353548f, -0.041355237f, -0.040360253f, -0.039365329f, -0.038381241f, -0.037407335f, -0.036442544f, -0.035484619f, -0.034533713f, -0.033587959f, -0.032647934f, -0.031710487f, -0.030775733f, -0.029841660f, -0.028906154f, -0.027971838f, -0.030693229f, -0.029804483f, -0.028912393f, -0.028025722f, -0.027142396f, -0.026263287f, -0.025387993f, -0.024512855f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.047386117f, -0.046586931f, -0.045732003f, -0.044818286f, -0.043841217f, -0.042841539f, -0.041840844f, -0.040841237f, -0.039844982f, -0.038855977f, -0.037876040f, -0.036907330f, -0.035944737f, -0.034990881f, -0.034040578f, -0.033097740f, -0.032157518f, -0.031221332f, -0.030284623f, -0.029350894f, -0.028413242f, -0.031135056f, -0.030244958f, -0.029353419f, -0.028466865f, -0.027584950f, -0.026704703f, -0.025830410f, -0.024957065f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.047883701f, -0.047083117f, -0.046228208f, -0.045313660f, -0.044332091f, -0.043330316f, -0.042325649f, -0.041324615f, -0.040323477f, -0.039328992f, -0.038344081f, -0.037370086f, -0.036403500f, -0.035445299f, -0.034492381f, -0.033547405f, -0.032603450f, -0.031664833f, -0.030727053f, -0.029792788f, -0.028854704f, -0.031573847f, -0.030682640f, -0.029793749f, -0.028904401f, -0.028022796f, -0.027144149f, -0.026271243f, -0.025397616f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.048385575f, -0.047586445f, -0.046729811f, -0.045812920f, -0.044829212f, -0.043824032f, -0.042816851f, -0.041812684f, -0.040809762f, -0.039812114f, -0.038822327f, -0.037841938f, -0.036871489f, -0.035909105f, -0.034951653f, -0.034002617f, -0.033057600f, -0.032116760f, -0.031177685f, -0.030240480f, -0.029303044f, -0.032018322f, -0.031128041f, -0.030238368f, -0.029349774f, -0.028466465f, -0.027589262f, -0.026716618f, -0.025845038f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.048894208f, -0.048092954f, -0.047236346f, -0.046317823f, -0.045331705f, -0.044322610f, -0.043312836f, -0.042305067f, -0.041299090f, -0.040298600f, -0.039302900f, -0.038317915f, -0.037341341f, -0.036374543f, -0.035414416f, -0.034461539f, -0.033513580f, -0.032569446f, -0.031628426f, -0.030690670f, -0.029752361f, -0.032465182f, -0.031574264f, -0.030684048f, -0.029795576f, -0.028913232f, -0.028033514f, -0.027161937f, -0.026289767f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.049414724f, -0.048612952f, -0.047756333f, -0.046834778f, -0.045844883f, -0.044832874f, -0.043819129f, -0.042808369f, -0.041799970f, -0.040796090f, -0.039794561f, -0.038803454f, -0.037822910f, -0.036851019f, -0.035887122f, -0.034929302f, -0.033978581f, -0.033032194f, -0.032089014f, -0.031149181f, -0.030209769f, -0.031095337f, -0.032028969f, -0.031138919f, -0.030249052f, -0.029364228f, -0.028488053f, -0.027614538f, -0.026745619f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.049938776f, -0.049136978f, -0.048277922f, -0.047353331f, -0.046361547f, -0.045345373f, -0.044328410f, -0.043313839f, -0.042303007f, -0.041296545f, -0.040292576f, -0.039295528f, -0.038308334f, -0.037331119f, -0.036364060f, -0.035402354f, -0.034447826f, -0.033498984f, -0.032553002f, -0.031612199f, -0.030670179f, -0.029731397f, -0.032486565f, -0.031595562f, -0.030705767f, -0.029821629f, -0.028943636f, -0.028072411f, -0.027201232f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.050465208f, -0.049663525f, -0.048803002f, -0.047876794f, -0.046882018f, -0.045860369f, -0.044840071f, -0.043823194f, -0.042809445f, -0.041799922f, -0.040792610f, -0.039789364f, -0.038797725f, -0.037815370f, -0.036842022f, -0.035876188f, -0.034920149f, -0.033966076f, -0.033019222f, -0.032075051f, -0.031133259f, -0.030191295f, -0.032943994f, -0.032051340f, -0.031164598f, -0.030278165f, -0.029401036f, -0.028528558f, -0.027659366f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.051002059f, -0.050199214f, -0.049337845f, -0.048409529f, -0.047409791f, -0.046386059f, -0.045361880f, -0.044341743f, -0.043322541f, -0.042310640f, -0.041300718f, -0.040294673f, -0.039296638f, -0.038309239f, -0.037331380f, -0.036361557f, -0.035399102f, -0.034443352f, -0.033494521f, -0.032547168f, -0.031603608f, -0.030661771f, -0.033413101f, -0.032519527f, -0.031629644f, -0.030743092f, -0.029864779f, -0.028992340f, -0.028122047f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.049987033f, -0.050743129f, -0.049878925f, -0.048947636f, -0.047945701f, -0.046916552f, -0.045888338f, -0.044864003f, -0.043843240f, -0.042828470f, -0.041814215f, -0.040806532f, -0.039801829f, -0.038808718f, -0.037824854f, -0.036851224f, -0.035885505f, -0.034926176f, -0.033972990f, -0.033023112f, -0.032077122f, -0.031134304f, -0.033882514f, -0.032987740f, -0.032097232f, -0.031211318f, -0.030331668f, -0.029458163f, -0.028588101f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.048967950f, -0.051287543f, -0.050421447f, -0.049487486f, -0.048480477f, -0.047448587f, -0.046416640f, -0.045389660f, -0.044364464f, -0.043345563f, -0.042328984f, -0.041318841f, -0.040311903f, -0.039312832f, -0.038323548f, -0.037344616f, -0.036374550f, -0.035410967f, -0.034454063f, -0.033502731f, -0.032554533f, -0.031609628f, -0.034355253f, -0.033459987f, -0.032567713f, -0.031680413f, -0.030800683f, -0.029925475f, -0.029056471f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.049515355f, -0.051838897f, -0.050970908f, -0.050033528f, -0.049022298f, -0.047985937f, -0.046949334f, -0.045918368f, -0.044890657f, -0.043868739f, -0.042849347f, -0.041836660f, -0.040827014f, -0.039820883f, -0.038826346f, -0.037843138f, -0.036868490f, -0.035900440f, -0.034939591f, -0.033985276f, -0.033035092f, -0.032087423f, -0.034830540f, -0.033934560f, -0.033042606f, -0.032152846f, -0.031271458f, -0.030397778f, -0.029527277f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.050068904f, -0.052395895f, -0.051525414f, -0.050584901f, -0.049571421f, -0.048529208f, -0.047488566f, -0.046452653f, -0.045422275f, -0.044396795f, -0.043375701f, -0.042357486f, -0.041345865f, -0.040333636f, -0.039333150f, -0.038343709f, -0.037364215f, -0.036392275f, -0.035428952f, -0.034470990f, -0.033517253f, -0.032567911f, -0.035308581f, -0.034408901f, -0.033516049f, -0.032625921f, -0.031743627f, -0.030867428f, -0.029997153f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.050631952f, -0.052961819f, -0.052089036f, -0.051145736f, -0.050125640f, -0.049081363f, -0.048035719f, -0.046996709f, -0.045961484f, -0.044933550f, -0.043907765f, -0.042888034f, -0.041872699f, -0.040858146f, -0.039851803f, -0.038856667f, -0.037872013f, -0.036895491f, -0.035926826f, -0.034965366f, -0.034008242f, -0.033058293f, -0.033954229f, -0.034895860f, -0.034000553f, -0.033109460f, -0.032224696f, -0.031350154f, -0.030477580f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.051201239f, -0.053535305f, -0.052660186f, -0.051713526f, -0.050689444f, -0.049638961f, -0.048589364f, -0.047545511f, -0.046505310f, -0.045473982f, -0.044445038f, -0.043422043f, -0.042404976f, -0.041387614f, -0.040373873f, -0.039372746f, -0.038382687f, -0.037401736f, -0.036429644f, -0.035464011f, -0.034505039f, -0.033550706f, -0.032601215f, -0.035384208f, -0.034485739f, -0.033592477f, -0.032708347f, -0.031830966f, -0.030959785f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.050197858f, -0.054110561f, -0.053232074f, -0.052281789f, -0.051252078f, -0.050197579f, -0.049143445f, -0.048094578f, -0.047050498f, -0.046014827f, -0.044982631f, -0.043957524f, -0.042936176f, -0.041917637f, -0.040901728f, -0.039894331f, -0.038898163f, -0.037912082f, -0.036934569f, -0.035966672f, -0.035002939f, -0.034046620f, -0.033093944f, -0.035874054f, -0.034973525f, -0.034079690f, -0.033192690f, -0.032314677f, -0.031441297f, -0.0013270393f, -0.0013270393f, -0.0013270393f, 
			-0.049204681f, -0.053101134f, -0.053821467f, -0.052866250f, -0.051831029f, -0.050771017f, -0.049712464f, -0.048659962f, -0.047611333f, -0.046571512f, -0.045536250f, -0.044507615f, -0.043483056f, -0.042460650f, -0.041442830f, -0.040428806f, -0.039426170f, -0.038434651f, -0.037452258f, -0.036480065f, -0.035512168f, -0.034552701f, -0.033598807f, -0.036375783f, -0.035472959f, -0.034577865f, -0.033688795f, -0.032809518f, -0.031934287f, -0.0013270393f, -0.0013270393f, -0.0013270393f };

  //IppiSize size; size.width = width; size.height = height;
  IppiSize size; size.width=stepFloat; size.height = height;

	int floodFillSize	= 0;
  
	ippiFloodFillGetSize_Grad(size, &floodFillSize);

  Ipp8u* pBuffer = static_cast<Ipp8u*>(ippsMalloc_8u(floodFillSize));
  memset (pBuffer, 0xcd, floodFillSize);

	IppiConnectedComp connectedComp;
	IppiPoint seed = {28,0};
  Ipp32f newVal = -0.019380737;
  Ipp32f floodFillMinValue = 0.00063999998f;

  ippiFloodFill_Grad8Con_32f_C1IR(image, step, size,
        seed, newVal,
        floodFillMinValue, 0.00064f,
        &connectedComp, pBuffer);

  ippsFree(pBuffer);
  pBuffer = nullptr;
}

 

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi Uta,

A bug was found in ippiFloodFillGetSize_Grad function making it to calculate wrong buffer size.
Please use the following workaround when using ippiFloodFill_Grad8Con_* and ippiFloodFill_Grad4Con_* functions.
After calling the ippiFloodFillGetSize_Grad function add to the returned buffer size the following (in bytes):
(ImageWidth * ImageHeight * 10) + 32

For example:

IppiSize ImageSize = {ImageWidth, ImageHeight};
int bufferSize = 0;

ippiFloodFillGetSize_Grad(ImageSize, &bufferSize);

bufferSize += (ImageSize.width * ImageSize.height * 10) + 32;
Ipp8u* pBuffer = (Ipp8u*) ippsMalloc_8u(bufferSize);

The next IPP release will contain all the necessary fixes.
Thank you for reporting this issue.

Best Regards,
Alexey

Leave a Comment

Please sign in to add a comment. Not a member? Join today