fix(utilities): reject empty sourceDS in BuildVRT/Warp/VectorTranslate#113
Merged
martende merged 1 commit intoMay 31, 2026
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #112.
Problem
BuildVRT,Warp, andVectorTranslateeach constructsrcDSfrom a caller-supplied[]Datasetand then unconditionally take the address ofsrcDS[0]to pass into the GDAL C API. IfsourceDSis empty, trivially reachable when callers build the slice dynamically and filter all entries out,&srcDS[0]panics withindex out of rangebefore the Cgo call runs.Fix
Bail out early with a descriptive error naming the function. Happy path and non-empty inputs are unchanged.
Test
gofmtclean. The repository requires a GDAL system library for fullgo testand can't be fully exercised on this machine, but the length-guard logic is trivial and self-contained.