Mercurial > hg > mlmmj
comparison src/chomp.c @ 753:b58fd7980358
Fix theoretically possible memory corruption by chomp()
A quick survey of callers of chomp() suggests this never could occur
in practice
author | Ben Schmidt |
---|---|
date | Wed, 06 Oct 2010 23:26:26 +1100 |
parents | 9935bcc6fc36 |
children |
comparison
equal
deleted
inserted
replaced
752:c02582939bbc | 753:b58fd7980358 |
---|---|
29 size_t i; | 29 size_t i; |
30 | 30 |
31 if(str == NULL) | 31 if(str == NULL) |
32 return NULL; | 32 return NULL; |
33 | 33 |
34 if(*str == '\0' || *str == '\n') { | 34 if(*str == '\0' || *str == '\n' || *str == '\r') { |
35 *str = '\0'; | 35 *str = '\0'; |
36 return str; | 36 return str; |
37 } | 37 } |
38 | 38 |
39 i = strlen(str) - 1; | 39 i = strlen(str) - 1; |