Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:coolo:alp:workbench
netpbm
ppmforge-fix-overflow.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ppmforge-fix-overflow.patch of Package netpbm
Index: netpbm/generator/ppmforge.c =================================================================== --- netpbm/generator/ppmforge.c (revision 4427) +++ netpbm/generator/ppmforge.c (revision 4428) @@ -241,7 +241,7 @@ static void -fourn(float * const data, +fourn(double * const data, const int * const nn, int const ndim, int const isign) { @@ -272,7 +272,7 @@ int i1, i2, i3; int i2rev, i3rev, ip1, ip2, ip3, ifp1, ifp2; int ibit, idim, k1, k2, n, nprev, nrem, ntot; - float tempi, tempr; + double tempi, tempr; double theta, wi, wpi, wpr, wr, wtemp; #define SWAP(a,b) tempr=(a); (a) = (b); (b) = tempr @@ -401,7 +401,7 @@ static void -spectralsynth(float ** const x, +spectralsynth(double ** const aP, unsigned int const n, double const h, struct Gauss * const gaussP) { @@ -411,18 +411,20 @@ This algorithm is given under the name SpectralSynthesisFM2D on page 108 of Peitgen & Saupe. -----------------------------------------------------------------------------*/ - unsigned bl; + unsigned int const bl = ((((unsigned long) n) * n) + 1) * 2; + int i, j, i0, j0, nsize[3]; double rad, phase, rcos, rsin; - float *a; + double * a; - bl = ((((unsigned long) n) * n) + 1) * 2 * sizeof(float); - a = (float *) calloc(bl, 1); - if (a == (float *) 0) { - pm_error("Cannot allocate %d x %d result array (% d bytes).", + MALLOCARRAY(a, bl); + + if (!a) { + pm_error("Cannot allocate %u x %u result array (%u doubles).", n, n, bl); } - *x = a; + for (i = 0; i < bl; ++i) + a[i] = 0.0; /* initial value */ for (i = 0; i <= n / 2; i++) { for (j = 0; j <= n / 2; j++) { @@ -463,6 +465,8 @@ nsize[0] = 0; nsize[1] = nsize[2] = n; /* Dimension of frequency domain array */ fourn(a, nsize, 2, -1); /* Take inverse 2D Fourier transform */ + + *aP = a; } @@ -572,9 +576,9 @@ static unsigned char * -makeCp(float * const a, - unsigned int const n, - pixval const maxval) { +makeCp(const double * const a, + unsigned int const n, + pixval const maxval) { /* Prescale the grid points into intensities. */ @@ -587,7 +591,7 @@ if (cp == NULL) pm_error("Unable to allocate %u bytes for cp array", n); - ap = cp; + ap = cp; /* initial value */ { unsigned int i; for (i = 0; i < n; i++) { @@ -603,7 +607,7 @@ static void createPlanetStuff(bool const clouds, - float * const a, + const double * const a, unsigned int const n, double ** const uP, double ** const u1P, @@ -977,7 +981,7 @@ static void genplanet(bool const stars, bool const clouds, - float * const a, + const double * const a, unsigned int const cols, unsigned int const rows, unsigned int const n, @@ -1052,7 +1056,7 @@ static void -applyPowerLawScaling(float * const a, +applyPowerLawScaling(double * const a, int const meshsize, double const powscale) { @@ -1065,7 +1069,7 @@ for (j = 0; j < meshsize; j++) { double const r = Real(a, i, j); if (r > 0) - Real(a, i, j) = pow(r, powscale); + Real(a, i, j) = MIN(hugeVal, pow(r, powscale)); } } } @@ -1074,10 +1078,10 @@ static void -computeExtremeReal(const float * const a, - int const meshsize, - double * const rminP, - double * const rmaxP) { +computeExtremeReal(const double * const a, + int const meshsize, + double * const rminP, + double * const rmaxP) { /* Compute extrema for autoscaling. */ @@ -1103,8 +1107,8 @@ static void -replaceWithSpread(float * const a, - int const meshsize) { +replaceWithSpread(double * const a, + int const meshsize) { /*---------------------------------------------------------------------------- Replace the real part of each element of the 'a' array with a measure of how far the real is from the middle; sort of a standard @@ -1138,7 +1142,7 @@ /*---------------------------------------------------------------------------- Make a planet. -----------------------------------------------------------------------------*/ - float * a; + double * a; bool error; struct Gauss gauss; @@ -1149,7 +1153,7 @@ error = FALSE; } else { spectralsynth(&a, meshsize, 3.0 - fracdim, &gauss); - if (a == NULL) { + if (!a) { error = TRUE; } else { applyPowerLawScaling(a, meshsize, powscale); Index: netpbm/test/ppmforge.test =================================================================== --- netpbm/test/ppmforge.test (revision 4427) +++ netpbm/test/ppmforge.test (revision 4428) @@ -47,6 +47,6 @@ -inclination 9 -hour 12 -power 200 > ${test_ppm} ppmforge -seed 1 -stars 0 -ice 0.01 \ -inclination 10 -hour 12 -power 200 | \ - pnmpsnr -target1=53.89 -target2=49.38 -target3=65.15 - ${test_ppm} + pnmpsnr -target1=46.07 -target2=52.00 -target3=67.77 - ${test_ppm} rm ${test_ppm}
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor