GNOME Bugzilla – Bug 796012
Several places in rebase.py incorrectly use `match.groups(1)` instead of `match.group(1)`, one causes a crash
Last modified: 2018-05-10 19:47:56 UTC
Created attachment 371907 [details] [review] fix for the bug There are several incorrect uses of `match.groups(1)` instead of `match.group(1)` in rebase.py - one was fixed in https://git.gnome.org/browse/gtk-doc/commit/?id=b77d97bfe0186eb727604dbad565dc4dde0eb273 , but three others remained. `match.groups(1)` is not *invalid*, but it does not do what any of these calls expect. The intent in each case is to get the contents of the subgroup 1 match as a string, but `match.groups(1)` doesn't do that. It returns a tuple of *all* the subgroup matches, with `1` used as the value for any which didn't actually capture any text (instead of the default `None` - that's what passing an arg to `groups()` does, changes the value used for subgroups that didn't capture anything). The case of this in `ReadIndex` would cause a crash if hit: Traceback (most recent call last):
+ Trace 238608
sys.exit(rebase.run(options))
ScanDirectory(dir, options)
ScanDirectory(subdir, options)
onlinedir = ReadIndex(scan_dir, entry)
onlinedir = re.sub(r'''(.*/).*''', r'\1', match.groups(1))
return _compile(pattern, flags).sub(repl, string, count)
As with https://bugzilla.gnome.org/show_bug.cgi?id=796011 , this crash got much easier to hit in 1.28 because of the fix to the `ReadDevhelp` regex in https://git.gnome.org/browse/gtk-doc/commit/?id=b77d97bfe0186eb727604dbad565dc4dde0eb273 . The other two occurrences, if I'm reading the code right, would not cause crashes, but would cause `RebaseLink` to fail (and log "Can't determine package for 'foo'") in cases where it ought to work. Patch attached.
Thanks for the patch. Pushed.