Răsfoiți Sursa

db_postgres: safety check to see if hasing is over non-null pointer

- inside implementation of replace command

(cherry picked from commit 9cd4aef84d8e7a079486ff73285a9bd6a15e8db3)
(cherry picked from commit 5d8315268e19538023d4127e74e166925ea216b8)
Daniel-Constantin Mierla 10 ani în urmă
părinte
comite
d7f1c9db34
1 a modificat fișierele cu 4 adăugiri și 4 ștergeri
  1. 4 4
      modules/db_postgres/km_dbase.c

+ 4 - 4
modules/db_postgres/km_dbase.c

@@ -862,12 +862,12 @@ int db_postgres_replace(const db1_con_t* _h, const db_key_t* _k,
 						pos += VAL_UINT(&_v[i]);
 						break;
 					case DB1_STR:
-						pos += get_hash1_raw((VAL_STR(&_v[i])).s,
-									(VAL_STR(&_v[i])).len);
+						pos += ((VAL_STR(&_v[i])).s)?get_hash1_raw((VAL_STR(&_v[i])).s,
+									(VAL_STR(&_v[i])).len):0;
 						break;
 					case DB1_STRING:
-						pos += get_hash1_raw(VAL_STRING(&_v[i]),
-									strlen(VAL_STRING(&_v[i])));
+						pos += (VAL_STRING(&_v[i]))?get_hash1_raw(VAL_STRING(&_v[i]),
+									strlen(VAL_STRING(&_v[i]))):0;
 						break;
 					default:
 						break;