summaryrefslogtreecommitdiff
path: root/ext/imap/imap.c
diff options
context:
space:
mode:
authorChuck Hagenbuch <chagenbu@php.net>2000-02-28 21:03:08 +0000
committerChuck Hagenbuch <chagenbu@php.net>2000-02-28 21:03:08 +0000
commitd3d45277a128e21a76db411749fdc7899ea0bb8c (patch)
tree428697a8f23f6cc3eef69488c2f4e847304c95c8 /ext/imap/imap.c
parent0e7e4d30f6d78bd6148c15527e571a1812cf513d (diff)
downloadphp-git-d3d45277a128e21a76db411749fdc7899ea0bb8c.tar.gz
fixing segfaults in imap_getmailboxes and imap_getsubscribed.
Diffstat (limited to 'ext/imap/imap.c')
-rw-r--r--ext/imap/imap.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/ext/imap/imap.c b/ext/imap/imap.c
index 38ba37adea..c0ba740a45 100644
--- a/ext/imap/imap.c
+++ b/ext/imap/imap.c
@@ -1396,16 +1396,15 @@ PHP_FUNCTION(imap_list)
/* Author: CJH */
PHP_FUNCTION(imap_list_full)
{
- pval *streamind, *ref, *pat, mboxob;
+ pval *streamind, *ref, *pat, *mboxob;
int ind, ind_type;
pils *imap_le_struct;
FOBJECTLIST *cur=NIL;
char *delim=NIL;
-
/* set flag for new, improved array of objects mailbox list */
folderlist_style = FLIST_OBJECT;
-
+
if (ARG_COUNT(ht)!=3
|| getParameters(ht,3,&streamind,&ref,&pat) == FAILURE) {
WRONG_PARAM_COUNT;
@@ -1414,9 +1413,8 @@ PHP_FUNCTION(imap_list_full)
convert_to_long(streamind);
convert_to_string(ref);
convert_to_string(pat);
-
+
ind = streamind->value.lval;
-
imap_le_struct = (pils *)zend_list_find(ind, &ind_type);
if (!imap_le_struct || !IS_STREAM(ind_type)) {
php_error(E_WARNING, "Unable to find stream pointer");
@@ -1428,21 +1426,23 @@ PHP_FUNCTION(imap_list_full)
if (imap_folder_objects == NIL) {
RETURN_FALSE;
}
+
array_init(return_value);
delim = emalloc(2 * sizeof(char));
cur=imap_folder_objects;
- while (cur != NIL ) {
- object_init(&mboxob);
- add_property_string(&mboxob, "name", cur->LTEXT,1);
- add_property_long(&mboxob, "attributes", cur->attributes);
+ while (cur != NIL) {
+ MAKE_STD_ZVAL(mboxob);
+ object_init(mboxob);
+ add_property_string(mboxob, "name", cur->LTEXT,1);
+ add_property_long(mboxob, "attributes", cur->attributes);
#ifdef IMAP41
delim[0] = (char)cur->delimiter;
delim[1] = 0;
- add_property_string(&mboxob, "delimiter", delim, 1);
+ add_property_string(mboxob, "delimiter", delim, 1);
#else
- add_property_string(&mboxob, "delimiter", cur->delimiter, 1);
+ add_property_string(mboxob, "delimiter", cur->delimiter, 1);
#endif
- add_next_index_object(return_value, &mboxob);
+ add_next_index_object(return_value, mboxob);
cur=cur->next;
}
mail_free_foblist(&imap_folder_objects);
@@ -1980,7 +1980,7 @@ PHP_FUNCTION(imap_lsub)
/* Author: CJH */
PHP_FUNCTION(imap_lsub_full)
{
- pval *streamind, *ref, *pat, mboxob;
+ pval *streamind, *ref, *pat, *mboxob;
int ind, ind_type;
pils *imap_le_struct;
FOBJECTLIST *cur=NIL;
@@ -1998,9 +1998,8 @@ PHP_FUNCTION(imap_lsub_full)
convert_to_long(streamind);
convert_to_string(ref);
convert_to_string(pat);
-
- ind = streamind->value.lval;
+ ind = streamind->value.lval;
imap_le_struct = (pils *)zend_list_find(ind, &ind_type);
if (!imap_le_struct || !IS_STREAM(ind_type)) {
php_error(E_WARNING, "Unable to find stream pointer");
@@ -2012,20 +2011,22 @@ PHP_FUNCTION(imap_lsub_full)
if (imap_sfolder_objects == NIL) {
RETURN_FALSE;
}
+
array_init(return_value);
cur=imap_sfolder_objects;
while (cur != NIL ) {
- object_init(&mboxob);
- add_property_string(&mboxob, "name", cur->LTEXT, 1);
- add_property_long(&mboxob, "attributes", cur->attributes);
+ MAKE_STD_ZVAL(mboxob);
+ object_init(mboxob);
+ add_property_string(mboxob, "name", cur->LTEXT, 1);
+ add_property_long(mboxob, "attributes", cur->attributes);
#ifdef IMAP41
delim[0] = (char)cur->delimiter;
delim[1] = 0;
- add_property_string(&mboxob, "delimiter", delim, 1);
+ add_property_string(mboxob, "delimiter", delim, 1);
#else
- add_property_string(&mboxob, "delimiter", cur->delimiter, 1);
+ add_property_string(mboxob, "delimiter", cur->delimiter, 1);
#endif
- add_next_index_object(return_value, &mboxob);
+ add_next_index_object(return_value, mboxob);
cur=cur->next;
}
mail_free_foblist (&imap_sfolder_objects);