Skip to content

Commit 8e053dc

Browse files
committed
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]
1 parent 027fa0f commit 8e053dc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/common/backup_compression.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,16 @@ parse_bc_specification(bc_algorithm algorithm, char *specification,
191191
if (value != NULL)
192192
pfree(value);
193193

194-
/* If we got an error or have reached the end of the string, stop. */
195-
if (result->parse_error != NULL || *kwend == '\0' || *vend == '\0')
194+
/*
195+
* If we got an error or have reached the end of the string, stop.
196+
*
197+
* If there is no value, then the end of the keyword might have been
198+
* the end of the string. If there is a value, then the end of the
199+
* keyword cannot have been the end of the string, but the end of the
200+
* value might have been.
201+
*/
202+
if (result->parse_error != NULL ||
203+
(vend == NULL ? *kwend == '\0' : *vend == '\0'))
196204
break;
197205

198206
/* Advance to next entry and loop around. */

0 commit comments

Comments
 (0)