the repository which powers this website
Avoid null pointer dereference in reencode().
Returning "*txt" if "txt" is a null pointer is a bad thing. Spotted with clang-analyzer. Signed-off-by: Lukas Fleischer <[email protected]> Signed-off-by: Lars Hjemli <[email protected]>
Lukas Fleischer 2011-05-24
parent 070e109 · commit a0bf375
-rw-r--r--parsing.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/parsing.c b/parsing.c
index c9e43509..151c0fe4 100644
--- a/parsing.c
+++ b/parsing.c
@@ -103,7 +103,10 @@ const char *reencode(char **txt, const char *src_enc, const char *dst_enc)
{
char *tmp;
- if (!txt || !*txt || !src_enc || !dst_enc)
+ if (!txt)
+ return NULL;
+
+ if (!*txt || !src_enc || !dst_enc)
return *txt;
/* no encoding needed if src_enc equals dst_enc */