[GRASS-git] [OSGeo/grass] 822943: r.clump: Fail with the clump limit instead of over...
R Sai Pranav
noreply at github.com
Wed Sep 23 10:05:40 PDT 2026
Branch: refs/heads/main
Home: https://github.com/OSGeo/grass
Commit: 8229439fe70f67ab86df4ad4f66ff9fba7ecc288
https://github.com/OSGeo/grass/commit/8229439fe70f67ab86df4ad4f66ff9fba7ecc288
Author: R Sai Pranav <rajasaipranav0 at gmail.com>
Date: 2026-09-23 (Wed, 23 Sep 2026)
Changed paths:
M raster/r.clump/clump.c
Log Message:
-----------
r.clump: Fail with the clump limit instead of overflowing the index (#7853)
* r.clump: Fail with the clump limit instead of overflowing the index
r.clump asked G_realloc() for 18446744065119617024 bytes and stopped with
a memory error, which reads as a memory problem when it is not one.
label and nalloc are both 32 bit. nalloc starts at INCR and grows in INCR
steps, so it lands exactly on 2^31 and wraps to INT_MIN, and
nalloc * sizeof(CELL) then converts to (size_t)(INT_MIN * 4), which is
18446744065119617024 - the number in the report.
Clump IDs are raster values of type CELL, so as @metzm said on the issue
the limit of one CELL cannot be raised. Report it as the limit it is
instead, and stop INCR short of INT_MAX so nalloc cannot overflow either.
Fixes #6412
* r.clump: Reword the clump limit message
Per review: say "the maximum supported number of clumps". Re-wrapped the
string so the lines stay within 80 columns.
To unsubscribe from these emails, change your notification settings at https://github.com/OSGeo/grass/settings/notifications
More information about the grass-commit
mailing list