summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2022-03-30 19:53:08 +0000
committerRobert Haas2022-03-30 19:53:08 +0000
commit8e053dc6dfbee4ae412e98ad73cfd4662d7453ac (patch)
tree11d701f6492402e88fe2d4a87a5466fd5cceeec7
parent027fa0fd72619a56d9d8877eedcb514331b63fa4 (diff)
Fix possible NULL-pointer-deference in backup_compression.c.
Per Coverity and Tom Lane. Reviewed by Tom Lane and Justin Pryzby. Discussion: http://postgr.es/m/[email protected]
-rw-r--r--src/common/backup_compression.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/common/backup_compression.c b/src/common/backup_compression.c
index 969e08cca20..867f2f2eb5e 100644
--- a/src/common/backup_compression.c
+++ b/src/common/backup_compression.c
@@ -191,8 +191,16 @@ parse_bc_specification(bc_algorithm algorithm, char *specification,
if (value != NULL)
pfree(value);
- /* If we got an error or have reached the end of the string, stop. */
- if (result->parse_error != NULL || *kwend == '\0' || *vend == '\0')
+ /*
+ * If we got an error or have reached the end of the string, stop.
+ *
+ * If there is no value, then the end of the keyword might have been
+ * the end of the string. If there is a value, then the end of the
+ * keyword cannot have been the end of the string, but the end of the
+ * value might have been.
+ */
+ if (result->parse_error != NULL ||
+ (vend == NULL ? *kwend == '\0' : *vend == '\0'))
break;
/* Advance to next entry and loop around. */