]> granicus.if.org Git - php/commitdiff
Fixed warning: "operation on ā€˜s’ may be undefined"
authorXinchen Hui <laruence@gmail.com>
Tue, 2 Aug 2016 12:28:42 +0000 (20:28 +0800)
committerXinchen Hui <laruence@gmail.com>
Tue, 2 Aug 2016 12:28:42 +0000 (20:28 +0800)
ext/standard/crypt.c

index 9e097ca6cf69269c36081ea9adc431abc73cce5c..f2f778e764b2f71a0329c0a8630e44327559ab24 100644 (file)
@@ -99,7 +99,8 @@ static unsigned char itoa64[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi
 static void php_to64(char *s, int n) /* {{{ */
 {
        while (--n >= 0) {
-               *s++ = itoa64[*s&0x3f];
+               *s = itoa64[*s & 0x3f];
+               s++;
        }
 }
 /* }}} */
@@ -244,16 +245,16 @@ PHP_FUNCTION(crypt)
        size_t str_len, salt_in_len = 0;
        zend_string *result;
 
+       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &str, &str_len, &salt_in, &salt_in_len) == FAILURE) {
+               return;
+       }
+
        salt[0] = salt[PHP_MAX_SALT_LEN] = '\0';
 
        /* This will produce suitable results if people depend on DES-encryption
         * available (passing always 2-character salt). At least for glibc6.1 */
        memset(&salt[1], '$', PHP_MAX_SALT_LEN - 1);
 
-       if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &str, &str_len, &salt_in, &salt_in_len) == FAILURE) {
-               return;
-       }
-
        if (salt_in) {
                memcpy(salt, salt_in, MIN(PHP_MAX_SALT_LEN, salt_in_len));
        } else {