Fixed a bug that caused a crash
This commit is contained in:
parent
4b381b72c9
commit
cd7dea33fc
|
@ -47,7 +47,7 @@ static void reportParseError(const char* phone_number, PhoneNumberUtil::ErrorTyp
|
||||||
errdetail("%s", parseErrorMessage(err))));
|
errdetail("%s", parseErrorMessage(err))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reportGenericError(std::exception& exception) {
|
static void reportGenericError(const std::exception& exception) {
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
|
(errcode(ERRCODE_EXTERNAL_ROUTINE_INVOCATION_EXCEPTION),
|
||||||
errmsg("C++ exception: %s", typeid(exception).name()),
|
errmsg("C++ exception: %s", typeid(exception).name()),
|
||||||
|
@ -86,9 +86,12 @@ ShortPhoneNumber* parsePhoneNumber(const char* number_str, const char* country)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
//TODO: check number validity.
|
//TODO: check number validity.
|
||||||
} catch(std::bad_alloc& e) {
|
} catch(const std::bad_alloc& e) {
|
||||||
reportOutOfMemory();
|
reportOutOfMemory();
|
||||||
} catch (std::exception& e) {
|
//TODO: figure out why we need this.
|
||||||
|
} catch(const PhoneNumberTooLongException& e) {
|
||||||
|
reportGenericError(e);
|
||||||
|
} catch(const std::exception& e) {
|
||||||
reportGenericError(e);
|
reportGenericError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,9 +167,9 @@ extern "C" {
|
||||||
result[len] = '\0';
|
result[len] = '\0';
|
||||||
|
|
||||||
PG_RETURN_CSTRING(result);
|
PG_RETURN_CSTRING(result);
|
||||||
} catch(std::bad_alloc& e) {
|
} catch(const std::bad_alloc& e) {
|
||||||
reportOutOfMemory();
|
reportOutOfMemory();
|
||||||
} catch (std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
reportGenericError(e);
|
reportGenericError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "phonenumbers/phonenumberutil.h"
|
#include "phonenumbers/phonenumberutil.h"
|
||||||
|
|
||||||
class PhoneNumberTooLongException : std::runtime_error {
|
class PhoneNumberTooLongException : public std::runtime_error {
|
||||||
public:
|
public:
|
||||||
PhoneNumberTooLongException(const i18n::phonenumbers::PhoneNumber& number, const char* msg);
|
PhoneNumberTooLongException(const i18n::phonenumbers::PhoneNumber& number, const char* msg);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue