aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/patch.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/toys/posix/patch.c b/toys/posix/patch.c
index d3d77792..f0caf8ae 100644
--- a/toys/posix/patch.c
+++ b/toys/posix/patch.c
@@ -327,7 +327,7 @@ void patch_main(void)
// Other versions of patch accept damaged patches, so we need to also.
if (strip || !patchlinenum++) {
int len = strlen(patchline);
- if (patchline[len-1] == '\r') {
+ if (len && patchline[len-1] == '\r') {
if (!strip && !FLAG(s)) fprintf(stderr, "Removing DOS newlines\n");
strip = 1;
patchline[len-1]=0;