*** GooString.cc.orig 2008-09-21 08:15:57.000000000 +0000 --- GooString.cc 2008-09-21 08:16:06.000000000 +0000 *************** GooString::GooString() { *** 161,166 **** --- 161,171 ---- GooString::GooString(const char *sA) { s = NULL; length = 0; + if (!sA) + { + Set(NULL); + return; + } Set(sA, CALC_STRING_LEN); } *************** GooString::GooString(const char *sA, int *** 173,178 **** --- 178,188 ---- GooString::GooString(GooString *str, int idx, int lengthA) { s = NULL; length = 0; + if (!str) + { + Set(NULL); + return; + } assert(idx + lengthA <= str->length); Set(str->getCString() + idx, lengthA); } *************** GooString::GooString(GooString *str, int *** 180,191 **** --- 190,211 ---- GooString::GooString(GooString *str) { s = NULL; length = 0; + if (!str) + { + Set(NULL); + return; + } Set(str->getCString(), str->length); } GooString::GooString(GooString *str1, GooString *str2) { s = NULL; length = 0; + if (!str1 || !str2) + { + Set(NULL); + return; + } Set(str1->getCString(), str1->length, str2->getCString(), str2->length); } *************** GooString *GooString::append(char c) { *** 231,240 **** --- 251,264 ---- } GooString *GooString::append(GooString *str) { + if ( !str) + return this; return append(str->getCString(), str->getLength()); } GooString *GooString::append(const char *str, int lengthA) { + if ( !str) + return this; int prevLen = length; if (CALC_STRING_LEN == lengthA) lengthA = strlen(str); *************** GooString *GooString::lowerCase() { *** 647,652 **** --- 671,678 ---- int GooString::cmp(GooString *str) { int n1, n2, i, x; char *p1, *p2; + if ( !str) + return 1; n1 = length; n2 = str->length; *************** int GooString::cmpN(GooString *str, int *** 663,668 **** --- 689,696 ---- int n1, n2, i, x; char *p1, *p2; + if ( !str) + return 1; n1 = length; n2 = str->length; for (i = 0, p1 = s, p2 = str->s; *************** int GooString::cmp(const char *sA) { *** 683,688 **** --- 711,718 ---- int n1, i, x; const char *p1, *p2; + if ( !sA) + return 1; n1 = length; for (i = 0, p1 = s, p2 = sA; i < n1 && *p2; ++i, ++p1, ++p2) { x = *p1 - *p2; *************** int GooString::cmpN(const char *sA, int *** 703,708 **** --- 733,740 ---- int n1, i, x; const char *p1, *p2; + if ( !sA) + return 1; n1 = length; for (i = 0, p1 = s, p2 = sA; i < n1 && *p2 && i < n; ++i, ++p1, ++p2) { x = *p1 - *p2; *************** int GooString::cmpN(const char *sA, int *** 724,728 **** --- 756,762 ---- GBool GooString::hasUnicodeMarker(void) { + if (!s ) + return (GBool)false; return (s[0] & 0xff) == 0xfe && (s[1] & 0xff) == 0xff; }