Skip to contentSkip to conversation

Properly skip over quoted values

PATCH In review Andrzej Zaborowski 2 participants 3 messages Nov 10, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Properly skip over quoted values

Otherwise a left paren in a string can bring an obscure segfault.

---
 gatchat/gatresult.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)
gatchat/gatresult.c +11 -0
index 3d07e13..688b26b 100644
@@ -361,6 +361,17 @@ static gint skip_until(const char *line, int start, const char delim)
 		if (line[i] == delim)
 			return i;
 
+		if (line[i] == '\"') {
+			i += 1;
+			while (i < len && line[i] != '\"')
+				i += 1;
+
+			if (i < len)
+				i += 1;
+
+			continue;
+		}
+
 		if (line[i] != '(') {
 			i += 1;
 			continue;
Signature · 1 line
1.6.1
#1 lore raw

Hi Andrew,

gatchat/gatresult.c static gint skip_until(const char *line, int start, const char delim) · line 374

Quoted 13 lines

Otherwise a left paren in a string can bring an obscure segfault.
---

gatchat/gatresult.c +11 -0
+		if (line[i] == '\"') {
+			i += 1;
+			while (i < len && line[i] != '\"')
+				i += 1;
+
+			if (i < len)
+				i += 1;
+
+			continue;
+		}
+

I suggest you recursively call skip_until here instead of duplicating the code. It also should be moved down and treated like '(' and ')'

Regards,
-Denis

#2 lore raw

Nevermind, I see why you did it this way. Patch has been applied.

Regards,
-Denis