/*
*******************************************************************************
-* Copyright (C) 1997-2006, International Business Machines Corporation and *
+* Copyright (C) 1997-2008, International Business Machines Corporation and *
* others. All Rights Reserved. *
*******************************************************************************
*
*/
static inline Formattable* createArrayCopy(const Formattable* array, int32_t count) {
Formattable *result = new Formattable[count];
- for (int32_t i=0; i<count; ++i) result[i] = array[i]; // Don't memcpy!
+ if (result != NULL) {
+ for (int32_t i=0; i<count; ++i)
+ result[i] = array[i]; // Don't memcpy!
+ }
return result;
}
}
break;
case kObject:
- equal = objectEquals(fValue.fObject, that.fValue.fObject);
+ if (fValue.fObject == NULL || that.fValue.fObject == NULL) {
+ equal = FALSE;
+ } else {
+ equal = objectEquals(fValue.fObject, that.fValue.fObject);
+ }
break;
}
return (int32_t)fValue.fDouble; // loses fraction
}
case Formattable::kObject:
+ if (fValue.fObject == NULL) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return 0;
+ }
// TODO Later replace this with instanceof call
if (instanceOfMeasure(fValue.fObject)) {
return ((const Measure*) fValue.fObject)->
return (int64_t)fValue.fDouble;
}
case Formattable::kObject:
+ if (fValue.fObject == NULL) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return 0;
+ }
// TODO Later replace this with instanceof call
if (instanceOfMeasure(fValue.fObject)) {
return ((const Measure*) fValue.fObject)->
case Formattable::kDouble:
return fValue.fDouble;
case Formattable::kObject:
+ if (fValue.fObject == NULL) {
+ status = U_MEMORY_ALLOCATION_ERROR;
+ return 0;
+ }
// TODO Later replace this with instanceof call
if (instanceOfMeasure(fValue.fObject)) {
return ((const Measure*) fValue.fObject)->
setError(status, U_INVALID_FORMAT_ERROR);
result.setToBogus();
} else {
- result = *fValue.fString;
+ if (fValue.fString == NULL) {
+ setError(status, U_MEMORY_ALLOCATION_ERROR);
+ } else {
+ result = *fValue.fString;
+ }
}
return result;
}
setError(status, U_INVALID_FORMAT_ERROR);
return *getBogus();
}
+ if (fValue.fString == NULL) {
+ setError(status, U_MEMORY_ALLOCATION_ERROR);
+ return *getBogus();
+ }
return *fValue.fString;
}
setError(status, U_INVALID_FORMAT_ERROR);
return *getBogus();
}
+ if (fValue.fString == NULL) {
+ setError(status, U_MEMORY_ALLOCATION_ERROR);
+ return *getBogus();
+ }
return *fValue.fString;
}