diff options
| author | Neil Conway <neilc@samurai.com> | 2005-07-01 05:12:06 +0000 |
|---|---|---|
| committer | Neil Conway <neilc@samurai.com> | 2005-07-01 05:12:06 +0000 |
| commit | 9fad4cb6047db0a0bfe0e183b046a7d87b810a74 (patch) | |
| tree | 7a92b44db187a59b589830c0d5ae75eed31e22de | |
| parent | 898a7bd13bb9d5ae36d2defcf3bbed3bd1d5ffd6 (diff) | |
| download | postgresql-9fad4cb6047db0a0bfe0e183b046a7d87b810a74.tar.gz | |
Fix some minor infelicities in ecpg's pgtypeslib: (1) `pstr' must be
non-NULL in this function, so there is no need to check for it (2) we
should check the return value of pgtypes_strdup(). Patch from Eric
Astor at EnterpriseDB, with slight cleanup by myself, per a report
from the Coverity tool.
| -rw-r--r-- | src/interfaces/ecpg/pgtypeslib/dt_common.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c index cc0170966c..b412c1b8ec 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt_common.c +++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c @@ -2669,8 +2669,7 @@ pgtypes_defmt_scan(union un_fmt_comb * scan_val, int scan_type, char **pstr, cha if (!pstr_end) { /* there was an error, no match */ - err = 1; - return err; + return 1; } last_char = *pstr_end; *pstr_end = '\0'; @@ -2699,8 +2698,10 @@ pgtypes_defmt_scan(union un_fmt_comb * scan_val, int scan_type, char **pstr, cha err = 1; break; case PGTYPES_TYPE_STRING_MALLOCED: - if (pstr) - scan_val->str_val = pgtypes_strdup(*pstr); + scan_val->str_val = pgtypes_strdup(*pstr); + if (scan_val->str_val == NULL) + err = 1; + break; } if (strtol_end && *strtol_end) *pstr = strtol_end; |
