cvs: pear /XMMS xmms.c
| From: | Rasmus Lerdorf | Date: | Mon, 13 Aug 2001 02:01:03 +0000 |
| Subject: | cvs: pear /XMMS xmms.c | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-486@lists.php.net to get a copy of this message | ||
rasmus Sun Aug 12 22:01:03 2001 EDT
Modified files:
/pear/XMMS xmms.c
Log:
Protect against NULL strings here
Index: pear/XMMS/xmms.c
diff -u pear/XMMS/xmms.c:1.9 pear/XMMS/xmms.c:1.10
--- pear/XMMS/xmms.c:1.9 Sun Aug 12 13:45:53 2001
+++ pear/XMMS/xmms.c Sun Aug 12 22:01:02 2001
@@ -241,6 +241,7 @@
long pos=-1;
pval *tmp_arr, **tmp, *var;
int len, i, single=0;
+ char *title, *file;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &var) == FAILURE)
return;
@@ -263,15 +264,19 @@
for(i=0; i<len; i++) {
MAKE_STD_ZVAL(tmp_arr);
array_init(tmp_arr);
- add_assoc_string(tmp_arr, "title", xmms_remote_get_playlist_title(XG(session),i), 1);
- add_assoc_string(tmp_arr, "file", xmms_remote_get_playlist_file(XG(session),i), 1);
+ title = xmms_remote_get_playlist_title(XG(session),i);
+ file = xmms_remote_get_playlist_file(XG(session),i);
+ add_assoc_string(tmp_arr, "title", title?title:"", 1);
+ add_assoc_string(tmp_arr, "file", file?file:"", 1);
add_assoc_double(tmp_arr, "time",
xmms_remote_get_playlist_time(XG(session),i)/1000.0);
zend_hash_index_update(Z_ARRVAL_P(return_value), i, &tmp_arr, sizeof(tmp_arr), NULL);
}
} else {
if(single) {
- add_assoc_string(return_value, "title",
xmms_remote_get_playlist_title(XG(session),pos), 1);
- add_assoc_string(return_value, "file", xmms_remote_get_playlist_file(XG(session),pos),
1);
+ title = xmms_remote_get_playlist_title(XG(session),pos);
+ file = xmms_remote_get_playlist_file(XG(session),pos);
+ add_assoc_string(return_value, "title", title?title:"", 1);
+ add_assoc_string(return_value, "file", file?file:"", 1);
add_assoc_double(return_value, "time",
xmms_remote_get_playlist_time(XG(session),pos)/1000.0);
} else {
/* We were passed an array of playlist positions to get info on */
@@ -280,8 +285,10 @@
convert_to_long_ex(tmp);
MAKE_STD_ZVAL(tmp_arr);
array_init(tmp_arr);
- add_assoc_string(tmp_arr, "title",
xmms_remote_get_playlist_title(XG(session),Z_LVAL_PP(tmp)), 1);
- add_assoc_string(tmp_arr, "file",
xmms_remote_get_playlist_file(XG(session),Z_LVAL_PP(tmp)), 1);
+ title = xmms_remote_get_playlist_title(XG(session),Z_LVAL_PP(tmp));
+ file = xmms_remote_get_playlist_file(XG(session),Z_LVAL_PP(tmp));
+ add_assoc_string(tmp_arr, "title", title?title:"", 1);
+ add_assoc_string(tmp_arr, "file", file?file:"", 1);
add_assoc_double(tmp_arr, "time",
xmms_remote_get_playlist_time(XG(session),Z_LVAL_PP(tmp))/1000.0);
zend_hash_index_update(Z_ARRVAL_P(return_value), Z_LVAL_PP(tmp), &tmp_arr, sizeof(tmp_arr),
NULL);
zend_hash_move_forward(Z_ARRVAL_P(var));
@@ -621,11 +628,11 @@
xmms_remote_get_info(XG(session), &rate, &freq, &nch);
array_init(return_value);
add_assoc_long(return_value, "pos", pos);
- add_assoc_string(return_value, "file", fn, 1);
- add_assoc_string(return_value, "title", title, 1);
+ add_assoc_string(return_value, "file", fn?fn:"", 1);
+ add_assoc_string(return_value, "title", title?title:"", 1);
add_assoc_double(return_value, "time", (double)(time/1000.0));
add_assoc_double(return_value, "timepos", (double)(timepos/1000.0));
- add_assoc_string(return_value, "status", status, 1);
+ add_assoc_string(return_value, "status", status?status:"", 1);
add_assoc_bool(return_value, "repeat", repeat);
add_assoc_bool(return_value, "shuffle", shuffle);
add_assoc_long(return_value, "rate", rate);