Re: [PATCH 2/3] tokenize: check if string is not NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 26/10/18 22:33, Luc Van Oostenryck wrote:
On Fri, Oct 26, 2018 at 04:26:31PM +0100, Ben Dooks wrote:
---
  tokenize.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tokenize.c b/tokenize.c
index 99b9580..c32f8c7 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -124,7 +124,7 @@ const char *show_string(const struct string *string)
  	char *ptr;
  	int i;
- if (!string->length)
+	if (!string || !string->length)
  		return "<bad_string>";

I don't understand this change. What about a zero-length string ("")?


The original checks for string->length but not if the string itself
was NULL. I've eliminated the original mistake that triggered this.

--
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux