summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEamon Walsh <ewalsh@tycho.nsa.gov>2011-08-02 01:05:48 -0400
committerEamon Walsh <ewalsh@tycho.nsa.gov>2011-08-02 01:05:48 -0400
commit18428562ad17413382687579b2fcd822247b98d4 (patch)
tree6ecbae13c8a3d0a9a6f227782132393e9b5611de
parent0af29aa2068f733388d4305f13fe455296644c65 (diff)
Fix length calculation bug in genimage utility program.
-rw-r--r--data/genimage.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/data/genimage.c b/data/genimage.c
index 78696e7..0b5650b 100644
--- a/data/genimage.c
+++ b/data/genimage.c
@@ -16,15 +16,18 @@
int main(int argc, char **argv)
{
- uint32_t width = htonl(gimp_image.width);
- uint32_t height = htonl(gimp_image.height);
+ uint32_t width, height, length;
unsigned i, r, g, b;
unsigned char pixel;
+ length = 3 * gimp_image.width * gimp_image.height;
+ width = htonl(gimp_image.width);
+ height = htonl(gimp_image.height);
+
write(1, &width, sizeof(width));
write(1, &height, sizeof(height));
- for (i = 0; i < width * height * 3; i += 3) {
+ for (i = 0; i < length; i += 3) {
r = gimp_image.pixel_data[i];
g = gimp_image.pixel_data[i + 1];
b = gimp_image.pixel_data[i + 2];