Commit 4467aea
committed
config_file: handle errors other than OOM while parsing section headers
The current code in `parse_section_header_ext` is only prepared to
properly handle out-of-memory conditions for the `git_buf` structure.
While very unlikely and probably caused by a programming error, it is
also possible to run into error conditions other than out-of-memory
previous to reaching the actual parsing loop. In these cases, we will
run into undefined behavior as the `rpos` variable is only initialized
after these triggerable errors, but we use it in the cleanup-routine.
Fix the issue by unifying the function's cleanup code with an
`end_error` section, which will not use the `rpos` variable.1 parent a25df00 commit 4467aea
1 file changed
+12
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
1030 | | - | |
| 1030 | + | |
1031 | 1031 | | |
1032 | 1032 | | |
1033 | 1033 | | |
1034 | 1034 | | |
1035 | 1035 | | |
1036 | 1036 | | |
1037 | 1037 | | |
1038 | | - | |
| 1038 | + | |
1039 | 1039 | | |
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
1043 | 1043 | | |
1044 | 1044 | | |
1045 | 1045 | | |
1046 | | - | |
| 1046 | + | |
1047 | 1047 | | |
1048 | 1048 | | |
1049 | 1049 | | |
| |||
1059 | 1059 | | |
1060 | 1060 | | |
1061 | 1061 | | |
1062 | | - | |
1063 | | - | |
| 1062 | + | |
1064 | 1063 | | |
1065 | 1064 | | |
1066 | 1065 | | |
| |||
1070 | 1069 | | |
1071 | 1070 | | |
1072 | 1071 | | |
1073 | | - | |
1074 | | - | |
| 1072 | + | |
1075 | 1073 | | |
1076 | 1074 | | |
1077 | 1075 | | |
| |||
1083 | 1081 | | |
1084 | 1082 | | |
1085 | 1083 | | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
| 1084 | + | |
| 1085 | + | |
1090 | 1086 | | |
1091 | 1087 | | |
1092 | 1088 | | |
| |||
1096 | 1092 | | |
1097 | 1093 | | |
1098 | 1094 | | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
1099 | 1100 | | |
1100 | 1101 | | |
1101 | 1102 | | |
| |||
0 commit comments