diff --git a/pdf.c b/pdf.c
index 6e6c6f61f8824b34174bc581978c6f58f7252482..37baee6faa43c2353007c774abb6f02299fc3ad7 100644
--- a/pdf.c
+++ b/pdf.c
@@ -1657,6 +1657,7 @@ new_lzw_spec(HBytes *bytes)
 {
 	size_t const BUFSIZE = sizeof(uint8_t) * 1024;
 	lzwspec *ret = malloc(sizeof(lzwspec));
+	memset(ret, 0, sizeof(lzwspec));
 	ret->input_stream = bytes;
 	ret->lzw_buf = malloc(BUFSIZE);
 	ret->total_buf_size = BUFSIZE;