summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sysfs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sysfs.c b/sysfs.c
index bc021cc..8979ec4 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -37,7 +37,7 @@ int load_sys(char *path, char *buf)
if (n <0 || n >= 1024)
return -1;
buf[n] = 0;
- if (buf[n-1] == '\n')
+ if (n && buf[n-1] == '\n')
buf[n-1] = 0;
return 0;
}