Skip to content

fix(utilities): reject empty sourceDS in BuildVRT/Warp/VectorTranslate#113

Merged
martende merged 1 commit into
lukeroth:masterfrom
SAY-5:fix/utilities-empty-source-panic-112
May 31, 2026
Merged

fix(utilities): reject empty sourceDS in BuildVRT/Warp/VectorTranslate#113
martende merged 1 commit into
lukeroth:masterfrom
SAY-5:fix/utilities-empty-source-panic-112

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented Apr 23, 2026

Fixes #112.

Problem

BuildVRT, Warp, and VectorTranslate each construct srcDS from a caller-supplied []Dataset and then unconditionally take the address of srcDS[0] to pass into the GDAL C API. If sourceDS is empty, trivially reachable when callers build the slice dynamically and filter all entries out, &srcDS[0] panics with index out of range before the Cgo call runs.

Fix

Bail out early with a descriptive error naming the function. Happy path and non-empty inputs are unchanged.

Test

gofmt clean. The repository requires a GDAL system library for full go test and can't be fully exercised on this machine, but the length-guard logic is trivial and self-contained.

BuildVRT, Warp, and VectorTranslate each construct srcDS from a
caller-supplied []Dataset and then unconditionally take the address
of srcDS[0] to pass to the GDAL C API. If sourceDS is empty (trivially
reachable when callers build the slice dynamically and all entries
get filtered out), &srcDS[0] panics with 'index out of range' before
the Cgo call runs.

Bail out early with a descriptive error naming the function. Happy
path and non-empty inputs are unchanged.

Refs lukeroth/gdal issue 112.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@martende martende merged commit 92db48c into lukeroth:master May 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runtime panic when empty slice is passed to BuildVRT, Warp, and VectorTranslate

2 participants