Skip to content

Commit c7de9e8

Browse files
serbel324ydbot
authored andcommitted
Fix segfault in version parser (#25587)
1 parent b2e8185 commit c7de9e8

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

ydb/core/driver_lib/version/ut/version_ut.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,19 @@ Y_UNIT_TEST_SUITE(YdbVersion) {
189189
false
190190
);
191191
}
192+
Y_UNIT_TEST(DefaulPatchTag) {
193+
Test(
194+
TCurrentCompatibilityInfo{
195+
.Application = "ydb",
196+
.Version = TVersion{ .Year = 25, .Major = 1, .Minor = 14 }
197+
},
198+
TCurrentCompatibilityInfo{
199+
.Application = "ydb",
200+
.Version = TVersion{ .Year = 25, .Major = 1, .Minor = 15, .Patch = 1 }
201+
},
202+
true
203+
);
204+
}
192205
Y_UNIT_TEST(LimitOld) {
193206
Test(
194207
TCurrentCompatibilityInfo{

ydb/core/driver_lib/version/version.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ std::optional<NKikimrConfig::TYdbVersion> ParseVersionFromTag(TString tag, TStri
429429

430430
if (parts.empty()) {
431431
// example: stable-22-1 == 22.1
432-
// major version, from which minor tags are formed
432+
// major version, from which minor branches are made
433433
return version;
434434
}
435435

@@ -442,10 +442,13 @@ std::optional<NKikimrConfig::TYdbVersion> ParseVersionFromTag(TString tag, TStri
442442
parts.pop_front();
443443
version.SetMinor(minor);
444444

445+
if (parts.empty()) {
446+
// example: stable-25-1-14 == 25.1.14
447+
// minor version, from which release tags are made
448+
return version;
449+
}
450+
445451
// parse Patch number
446-
// We don't need to parse versions without Patch component, since this
447-
// code only present in newer trunks and stables >=25.1, where Patch is
448-
// already introduced, and only used to parse local
449452
ui32 patch;
450453
if (!TryIntFromString<10, ui32>(parts.front(), patch)) {
451454
// example: stable-25-1-1-prestablle == 25.1.1

0 commit comments

Comments
 (0)