Commits

Marc Fournier committed 950b6ab

Fixes: Using LIKE or ~ operator on text type files which are null valued
causes segmentation fault.

Thanks to: Salvador Ortiz Garcia, Robert Patrick, Paul 'Shag' Walmsley,
and James Cooper for finding and fixing the problem.

Comments (0)

Files changed (2)

src/backend/utils/adt/like.c

 bool 
 namelike(NameData *n, struct varlena *p)
 {
+    if (!n) return FALSE;
     return (fixedlen_like(n->data, p, NAMEDATALEN));
 }
 
 bool 
 textlike(struct varlena *s, struct varlena *p)
 {
+    if (!s) return FALSE;
     return (fixedlen_like(VARDATA(s), p, VARSIZE(s) - VARHDRSZ));
 }
 
 }
 
 
-/*  $Revision: 1.1.1.1 $
+/*  $Revision: 1.2 $
 **  "like.c" A first attempt at a LIKE operator for Postgres95.
 **
 **  Originally written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986.

src/backend/utils/adt/regexp.c

  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.1.1.1 1996/07/09 06:22:05 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.2 1996/07/09 06:39:19 scrappy Exp $
  *
  *      Alistair Crooks added the code for the regex caching
  *	agc - cached the regular expressions used - there's a good chance
 bool 
 nameregexeq(NameData *n, struct varlena *p)
 {
+    if (!n) return FALSE;
     return (fixedlen_regexeq(n->data, p, NAMEDATALEN, REG_EXTENDED));
 }
 bool 
 bool 
 textregexeq(struct varlena *s, struct varlena *p)
 {
+    if (!s) return (FALSE);
     return (fixedlen_regexeq(VARDATA(s), p, VARSIZE(s) - VARHDRSZ, REG_EXTENDED));
 }
 
 bool 
 texticregexeq(struct varlena *s, struct varlena *p)
 {
+    if (!s) return FALSE;
     return (fixedlen_regexeq(VARDATA(s), p, VARSIZE(s) - VARHDRSZ, 
 			     REG_ICASE | REG_EXTENDED));
 }
 bool 
 nameicregexeq(NameData *n, struct varlena *p)
 {
+    if (!n) return FALSE;
     return (fixedlen_regexeq(n->data, p, NAMEDATALEN, 
 			     REG_ICASE | REG_EXTENDED));
 }