Bug 235733

Summary: g_utf8_validate() failed to allocate 4294967296 bytes
Product: [Fedora] Fedora Reporter: Olivier Fourdan <fourdan>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6   
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-04-10 05:47:25 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Olivier Fourdan 2007-04-09 20:24:02 UTC
Description of problem:

Using g_utf8_validate() with param length set as -1 cause the following terror
on x86_64:

GLib-ERROR **: gmem.c:172: failed to allocate 4294967296 bytes

Looks like -1 is interpreted as an unsigned, thus the 4294967296

The API of g_utf8_validate() says: 

max_len : 	 max bytes to validate, or -1 to go until NUL

[1]
http://developer.gnome.org/doc/API/2.0/glib/glib-Unicode-Manipulation.html#g-utf8-validate

Version-Release number of selected component (if applicable):

gcc-4.1.1-51.fc6
glib2-2.12.9-1.fc6
glib2-2.12.9-1.fc6

How reproducible:


Steps to Reproduce:
Just use the following call in  g_utf8_validate (string, -1, NULL)
  
Actual results:


Expected results:


Additional info:

This works as expected on other x86_64 distributions like Ubuntu or Debian.

Comment 1 Olivier Fourdan 2007-04-10 05:47:25 UTC
Never mind, I cannot reproduce that problem with a simple test case, so it's
something else. Sorry for the false alarm...

Comment 2 Jakub Jelinek 2007-04-13 10:49:46 UTC
My guess would be you were calling g_utf8_validate without including the right
header with a prototype.  Without a prototype, -1 will be passed as
0xffffffffUL in the corresponding register, while -1L or with a prototype
which has long type for the parameter as -1L (== 0xffffffffffffffffL).