Skip to content

Commit

Permalink
r.neighbors: fix integer overflow (#2856)
Browse files Browse the repository at this point in the history
  • Loading branch information
metzm authored Feb 24, 2023
1 parent c70e2b0 commit 8cbca8b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions raster/r.neighbors/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ int main(int argc, char *argv[])
/* ncb.buf length is region row length + 2 * ncb.dist (eq. floor(neighborhood/2))
* Thus original data start is shifted by ncb.dist! */
for (i = 0; i < num_outputs; i++)
outputs[i].buf[brow_idx * ncols + col] = ncb.buf[t][ncb.dist][col + ncb.dist];
outputs[i].buf[(size_t)brow_idx * ncols + col] = ncb.buf[t][ncb.dist][col + ncb.dist];
continue;
}

Expand All @@ -538,7 +538,7 @@ int main(int argc, char *argv[])

for (i = 0; i < num_outputs; i++) {
struct output *out = &outputs[i];
DCELL *rp = &out->buf[brow_idx * ncols + col];
DCELL *rp = &out->buf[(size_t)brow_idx * ncols + col];

if (n == 0) {
Rast_set_d_null_value(rp, 1);
Expand Down

0 comments on commit 8cbca8b

Please sign in to comment.