Refactor `switch_fulldate_cmp`
We're moving the variable declarations down to the smallest possible scope (a good idea in general) so we can address the use of undefined memory by the function in a later commit.
This commit is contained in:
parent
b2f59dd200
commit
bf42dd65f1
|
@ -2994,21 +2994,19 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
|
||||||
char *dup = strdup(exp);
|
char *dup = strdup(exp);
|
||||||
char *sStart;
|
char *sStart;
|
||||||
char *sEnd;
|
char *sEnd;
|
||||||
char *sDate;
|
|
||||||
char *sTime;
|
|
||||||
switch_time_t tsStart;
|
|
||||||
switch_time_t tsEnd;
|
|
||||||
struct tm tmTmp;
|
|
||||||
int year, month, day;
|
|
||||||
int hour, min, sec;
|
|
||||||
|
|
||||||
switch_assert(dup);
|
switch_assert(dup);
|
||||||
|
|
||||||
sStart = dup;
|
sStart = dup;
|
||||||
if ((sEnd=strchr(dup, '~'))) {
|
if ((sEnd=strchr(dup, '~'))) {
|
||||||
|
char *sDate = sStart;
|
||||||
|
char *sTime;
|
||||||
*sEnd++ = '\0';
|
*sEnd++ = '\0';
|
||||||
sDate = sStart;
|
|
||||||
if ((sTime=strchr(sStart, ' '))) {
|
if ((sTime=strchr(sStart, ' '))) {
|
||||||
|
switch_time_t tsStart;
|
||||||
|
struct tm tmTmp;
|
||||||
|
int year, month, day;
|
||||||
|
int hour, min, sec;
|
||||||
*sTime++ = '\0';
|
*sTime++ = '\0';
|
||||||
|
|
||||||
memset(&tmTmp, 0, sizeof(tmTmp));
|
memset(&tmTmp, 0, sizeof(tmTmp));
|
||||||
|
@ -3026,6 +3024,10 @@ SWITCH_DECLARE(int) switch_fulldate_cmp(const char *exp, switch_time_t *ts)
|
||||||
|
|
||||||
sDate = sEnd;
|
sDate = sEnd;
|
||||||
if ((sTime=strchr(sEnd, ' '))) {
|
if ((sTime=strchr(sEnd, ' '))) {
|
||||||
|
switch_time_t tsEnd;
|
||||||
|
struct tm tmTmp;
|
||||||
|
int year, month, day;
|
||||||
|
int hour, min, sec;
|
||||||
*sTime++ = '\0';
|
*sTime++ = '\0';
|
||||||
|
|
||||||
memset(&tmTmp, 0, sizeof(tmTmp));
|
memset(&tmTmp, 0, sizeof(tmTmp));
|
||||||
|
|
Loading…
Reference in New Issue