Jelajahi Sumber

Fix problem in the previous commit: use ntohl() instead of ntohs() when
converting int4 and cast result to int32_t not int16_t.

Maxim Sobolev 17 tahun lalu
induk
melakukan
6b51c9e626
1 mengubah file dengan 2 tambahan dan 2 penghapusan
  1. 2 2
      modules/db_postgres/pg_fld.c

+ 2 - 2
modules/db_postgres/pg_fld.c

@@ -627,7 +627,7 @@ static inline int pg_int4_2_db_cstr(db_fld_t* fld, char* val, int len)
 	struct pg_fld* pfld = DB_GET_PAYLOAD(fld);
 	int size, v;
 
-	v = (int16_t)ntohs(*((int32_t*)val));
+	v = (int32_t)ntohl(*((int32_t*)val));
 
     size = snprintf(pfld->buf, INT2STR_MAX_LEN, "%-d", v);
     if (len < 0 || size >= INT2STR_MAX_LEN) {
@@ -664,7 +664,7 @@ static inline int pg_int4_2_db_str(db_fld_t* fld, char* val, int len)
 	struct pg_fld* pfld = DB_GET_PAYLOAD(fld);
 	int size, v;
 
-	v = (int16_t)ntohs(*((int32_t*)val));
+	v = (int32_t)ntohl(*((int32_t*)val));
 
     size = snprintf(pfld->buf, INT2STR_MAX_LEN, "%-d", v);
     if (size < 0 || size >= INT2STR_MAX_LEN) {