Title: readline: setlocale() returns NULL on Android
Type: Stage:
Components: Cross-Build Versions: Python 3.4, Python 3.5, Python 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List:, matrixise, vstinner
Priority: normal Keywords: patch

Created on 2014-04-30 07:33 by, last changed 2014-04-30 09:56 by matrixise.

File name Uploaded Description Edit
strdup.patch, 2014-04-30 07:33 review
readline_android.patch vstinner, 2014-04-30 09:52 review
Messages (3)
msg217580 - (view) Author: Li Zhenhua ( * Date: 2014-04-30 07:33
On Android platform, when run "python" command without any scripts, it may crash, get an error message "Segment Fault". This is because strdup with a NULL pointer. 

In file 
    static void setup_readline(void)

This line:
    char *saved_locale = strdup(setlocale(LC_CTYPE, NULL));

When running on an Android platform, setlocale(LC_CTYPE, NULL) returns NULL, and this causes strdup with a NULL pointer, then Segment Fault occurs.
msg217589 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-04-30 09:52
Here is a patch.
msg217590 - (view) Author: St├ęphane Wirtel (matrixise) * (Python committer) Date: 2014-04-30 09:56
+1 for the patch
Date User Action Args
2014-04-30 09:56:09matrixisesetnosy: + matrixise
messages: + msg217590
2014-04-30 09:52:45vstinnersetfiles: + readline_android.patch
title: strdup may cause Segment Fault on Android -> readline: setlocale() returns NULL on Android
nosy: + vstinner

messages: + msg217589

versions: + Python 2.7, Python 3.4
2014-04-30 07:33:43lizhenhua.devcreate