mem1v1-memcpy-overlap.patch

text/plain

Filename: mem1v1-memcpy-overlap.patch
Type: text/plain
Part: 0
Message: memory-related bugs

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
File+
src/backend/access/common/tupdesc.c 0 0
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index d78b083..1ed7195 100644
*** a/src/backend/access/common/tupdesc.c
--- b/src/backend/access/common/tupdesc.c
***************
*** 459,468 **** TupleDescInitEntry(TupleDesc desc,
  	 * fill in valid resname values in targetlists, particularly for resjunk
  	 * attributes.
  	 */
! 	if (attributeName != NULL)
! 		namestrcpy(&(att->attname), attributeName);
! 	else
  		MemSet(NameStr(att->attname), 0, NAMEDATALEN);
  
  	att->attstattarget = -1;
  	att->attcacheoff = -1;
--- 459,468 ----
  	 * fill in valid resname values in targetlists, particularly for resjunk
  	 * attributes.
  	 */
! 	if (attributeName == NULL)
  		MemSet(NameStr(att->attname), 0, NAMEDATALEN);
+ 	else if (attributeName != &(att->attname))
+ 		namestrcpy(&(att->attname), attributeName);
  
  	att->attstattarget = -1;
  	att->attcacheoff = -1;
diff --git a/src/backend/tsearch/dict_ispeindex 31929c0..bfd1732 100644
*** a/src/backend/tsearch/dict_ispell.c
--- b/src/backend/tsearch/dict_ispell.c
***************
*** 139,145 **** dispell_lexize(PG_FUNCTION_ARGS)
  		}
  		else
  		{
! 			memcpy(cptr, ptr, sizeof(TSLexeme));
  			cptr++;
  			ptr++;
  		}
--- 139,146 ----
  		}
  		else
  		{
! 			if (ptr != cptr)
! 				memcpy(cptr, ptr, sizeof(TSLexeme));
  			cptr++;
  			ptr++;
  		}
diff --git a/src/backend/utils/adt/tsvecindex 6810615..6c24850 100644
*** a/src/backend/utils/adt/tsvector.c
--- b/src/backend/utils/adt/tsvector.c
***************
*** 125,131 **** uniqueentry(WordEntryIN *a, int l, char *buf, int *outbuflen)
  				buflen += res->poslen * sizeof(WordEntryPos) + sizeof(uint16);
  			}
  			res++;
! 			memcpy(res, ptr, sizeof(WordEntryIN));
  		}
  		else if (ptr->entry.haspos)
  		{
--- 125,132 ----
  				buflen += res->poslen * sizeof(WordEntryPos) + sizeof(uint16);
  			}
  			res++;
! 			if (ptr != res)
! 				memcpy(res, ptr, sizeof(WordEntryIN));
  		}
  		else if (ptr->entry.haspos)
  		{