فهرست منبع

Fix a valgrind warning.

Adam Ierymenko 9 سال پیش
والد
کامیت
b4fcf2ee60
1فایلهای تغییر یافته به همراه6 افزوده شده و 4 حذف شده
  1. 6 4
      node/Dictionary.hpp

+ 6 - 4
node/Dictionary.hpp

@@ -66,8 +66,10 @@ public:
 
 	Dictionary(const char *s,unsigned int len)
 	{
-		memcpy(_d,s,(len > C) ? (unsigned int)C : len);
-		_d[C-1] = (char)0;
+		if (len > C)
+			len = C;
+		memcpy(_d,s,len);
+		_d[len-1] = (char)0;
 	}
 
 	Dictionary(const Dictionary &d)
@@ -161,7 +163,7 @@ public:
 				j = 0;
 				esc = false;
 				++p;
-				while ((*p)&&(*p != '\r')&&(*p != '\n')) {
+				while ((*p != 0)&&(*p != '\r')&&(*p != '\n')) {
 					if (esc) {
 						esc = false;
 						switch(*p) {
@@ -308,7 +310,7 @@ public:
 
 				p = value;
 				int k = 0;
-				while ( ((*p)&&(vlen < 0)) || (k < vlen) ) {
+				while ( ((vlen < 0)&&(*p)) || (k < vlen) ) {
 					switch(*p) {
 						case 0:
 						case '\r':