fix strncpy call (uninitialized memory read)

This commit is contained in:
Guido van Rossum 1995-01-20 16:59:12 +00:00
parent badadd2165
commit ec4982761b
1 changed files with 2 additions and 1 deletions

View File

@ -168,7 +168,8 @@ parsetok(tok, g, start, err_ret)
int len = tok->inp - tok->buf; int len = tok->inp - tok->buf;
err_ret->text = malloc(len + 1); err_ret->text = malloc(len + 1);
if (err_ret->text != NULL) { if (err_ret->text != NULL) {
strncpy(err_ret->text, tok->buf, len+1); if (len > 0)
strncpy(err_ret->text, tok->buf, len);
err_ret->text[len] = '\0'; err_ret->text[len] = '\0';
} }
} }