pajoye                                   Thu, 28 Jul 2011 10:42:45 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=313831

Log:
- Fix #55301 (readline part) check if malloc succeded

Bug: https://bugs.php.net/55301 (error getting bug information)
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/readline/readline.c
    U   php/php-src/branches/PHP_5_4/ext/readline/readline.c
    U   php/php-src/trunk/ext/readline/readline.c

Modified: php/php-src/branches/PHP_5_3/ext/readline/readline.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/readline/readline.c        2011-07-28 
10:39:19 UTC (rev 313830)
+++ php/php-src/branches/PHP_5_3/ext/readline/readline.c        2011-07-28 
10:42:45 UTC (rev 313831)
@@ -465,6 +465,9 @@
                                matches = 
rl_completion_matches(text,_readline_command_generator);
                        } else {
                                matches = malloc(sizeof(char *) * 2);
+                               if (!matches) {
+                                       return NULL;
+                               }
                                matches[0] = strdup("");
                                matches[1] = '\0';
                        }
@@ -505,7 +508,10 @@
        zval_copy_ctor(_readline_completion);

        rl_attempted_completion_function = _readline_completion_cb;
-
+       if (rl_attempted_completion_function == NULL) {
+               efree(name);
+               RETURN_FALSE;
+       }
        RETURN_TRUE;
 }


Modified: php/php-src/branches/PHP_5_4/ext/readline/readline.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/readline/readline.c        2011-07-28 
10:39:19 UTC (rev 313830)
+++ php/php-src/branches/PHP_5_4/ext/readline/readline.c        2011-07-28 
10:42:45 UTC (rev 313831)
@@ -478,6 +478,9 @@
                                matches = 
rl_completion_matches(text,_readline_command_generator);
                        } else {
                                matches = malloc(sizeof(char *) * 2);
+                               if (!matches) {
+                                       return NULL;
+                               }
                                matches[0] = strdup("");
                                matches[1] = '\0';
                        }
@@ -518,7 +521,10 @@
        zval_copy_ctor(_readline_completion);

        rl_attempted_completion_function = _readline_completion_cb;
-
+       if (rl_attempted_completion_function == NULL) {
+               efree(name);
+               RETURN_FALSE;
+       }
        RETURN_TRUE;
 }


Modified: php/php-src/trunk/ext/readline/readline.c
===================================================================
--- php/php-src/trunk/ext/readline/readline.c   2011-07-28 10:39:19 UTC (rev 
313830)
+++ php/php-src/trunk/ext/readline/readline.c   2011-07-28 10:42:45 UTC (rev 
313831)
@@ -478,6 +478,9 @@
                                matches = 
rl_completion_matches(text,_readline_command_generator);
                        } else {
                                matches = malloc(sizeof(char *) * 2);
+                               if (!matches) {
+                                       return NULL;
+                               }
                                matches[0] = strdup("");
                                matches[1] = '\0';
                        }
@@ -518,7 +521,10 @@
        zval_copy_ctor(_readline_completion);

        rl_attempted_completion_function = _readline_completion_cb;
-
+       if (rl_attempted_completion_function == NULL) {
+               efree(name);
+               RETURN_FALSE;
+       }
        RETURN_TRUE;
 }


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to