[issue28187] Check return value of _PyBytes_Resize

2016-09-17 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the review, Serhiy! Good point, closing this as 'not a bug'.

--
resolution:  -> not a bug
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28187] Check return value of _PyBytes_Resize

2016-09-17 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

In all cases _PyBytes_Resize is followed by return. Original code is correct. 
In either way NULL is returned if _PyBytes_Resize fails.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28187] Check return value of _PyBytes_Resize

2016-09-17 Thread Berker Peksag

Changes by Berker Peksag :


Added file: http://bugs.python.org/file44711/pybytes_resize_regenerated.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28187] Check return value of _PyBytes_Resize

2016-09-17 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Could you please regenerate the patch for Rietveld Berker?

_PyBytes_Resize(&res, r) always sets res to NULL if fails. Thus the following 
code is correct. No need to check the return value.

if (n > r)
_PyBytes_Resize(&res, r);
return res;

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28187] Check return value of _PyBytes_Resize

2016-09-17 Thread Christian Heimes

Christian Heimes added the comment:

Yes, it can fail for multiple reasons: wrong type, ref count != 1, realloc() 
fails to allocate a smaller area.

--
nosy: +christian.heimes

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28187] Check return value of _PyBytes_Resize

2016-09-17 Thread Martin Panter

Martin Panter added the comment:

Can the resize fail if the buffer is only being strunk? I haven’t looked 
closely, but maybe that’s why some of the cases don’t check for failure.

--
nosy: +martin.panter

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28187] Check return value of _PyBytes_Resize

2016-09-17 Thread Berker Peksag

New submission from Berker Peksag:

There are a couple of instances that don't check return value of 
_PyBytes_Resize in Modules/. I noticed this while working on issue 25270.

Patch attached.

--
components: Extension Modules
files: pybytes_resize.diff
keywords: patch
messages: 276778
nosy: berker.peksag, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Check return value of _PyBytes_Resize
type: behavior
versions: Python 3.6, Python 3.7
Added file: http://bugs.python.org/file44710/pybytes_resize.diff

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com