[PATCH 10/12] btrfs-progs: don't overflow colors[] in fragments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stop iteration at the number of elements in the colors[] array when
initializing the elements.  Rather than a magic number.  This was found
by static analysis.

Signed-off-by: Zach Brown <zab@xxxxxxxxxx>
---
 btrfs-fragments.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/btrfs-fragments.c b/btrfs-fragments.c
index 4dd9470..cedbc57 100644
--- a/btrfs-fragments.c
+++ b/btrfs-fragments.c
@@ -283,7 +283,7 @@ list_fragments(int fd, u64 flags, char *dir)
 				white = gdImageColorAllocate(im, 255, 255, 255);
 				black = gdImageColorAllocate(im, 0, 0, 0);  
 
-				for (j = 0; j < 10; ++j)
+				for (j = 0; j < ARRAY_SIZE(colors); ++j)
 					colors[j] = black;
 
 				init_colors(im, colors);
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux