summaryrefslogtreecommitdiff
path: root/tools.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2006-01-20 14:02:17 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2006-01-20 14:02:17 +0100
commitc60129ed78f328a323486f8c853e66d252f9aebf (patch)
treed5e5d65fa8513c05c0ae45ae46ce9575ffaaecbf /tools.c
parented9b548d6eafce5d587ba598896d9c874ba383de (diff)
downloadvdr-c60129ed78f328a323486f8c853e66d252f9aebf.tar.gz
vdr-c60129ed78f328a323486f8c853e66d252f9aebf.tar.bz2
Improved NULL checking in strreplace()
Diffstat (limited to 'tools.c')
-rw-r--r--tools.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/tools.c b/tools.c
index 85fd4061..031c120a 100644
--- a/tools.c
+++ b/tools.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: tools.c 1.111 2006/01/15 16:42:37 kls Exp $
+ * $Id: tools.c 1.112 2006/01/20 14:01:28 kls Exp $
*/
#include "tools.h"
@@ -138,13 +138,14 @@ char *strn0cpy(char *dest, const char *src, size_t n)
char *strreplace(char *s, char c1, char c2)
{
- char *p = s;
-
- while (p && *p) {
- if (*p == c1)
- *p = c2;
- p++;
- }
+ if (s) {
+ char *p = s;
+ while (*p) {
+ if (*p == c1)
+ *p = c2;
+ p++;
+ }
+ }
return s;
}