Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9fad4cb

Browse files
author
Neil Conway
committed
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.
1 parent 898a7bd commit 9fad4cb

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/interfaces/ecpg/pgtypeslib/dt_common.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -2669,8 +2669,7 @@ pgtypes_defmt_scan(union un_fmt_comb * scan_val, int scan_type, char **pstr, cha
26692669
if (!pstr_end)
26702670
{
26712671
/* there was an error, no match */
2672-
err = 1;
2673-
return err;
2672+
return 1;
26742673
}
26752674
last_char = *pstr_end;
26762675
*pstr_end = '\0';
@@ -2699,8 +2698,10 @@ pgtypes_defmt_scan(union un_fmt_comb * scan_val, int scan_type, char **pstr, cha
26992698
err = 1;
27002699
break;
27012700
case PGTYPES_TYPE_STRING_MALLOCED:
2702-
if (pstr)
2703-
scan_val->str_val = pgtypes_strdup(*pstr);
2701+
scan_val->str_val = pgtypes_strdup(*pstr);
2702+
if (scan_val->str_val == NULL)
2703+
err = 1;
2704+
break;
27042705
}
27052706
if (strtol_end && *strtol_end)
27062707
*pstr = strtol_end;

0 commit comments

Comments
 (0)