Re: patch: General purpose utility functions used by the JSON data type

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch: General purpose utility functions used by the JSON data type
Date: 2010-08-13 17:02:11
Message-ID: 29820.1281718931@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Joseph Adams <joeyadams3(dot)14159(at)gmail(dot)com> writes:
> On Fri, Aug 13, 2010 at 10:46 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> + if (sub_end + len > e)
>> + {
>> + Assert(false); /* Clipped multibyte character */
>> + break;
>> + }

> If I simply say Assert(sub_end + len <= e), the function will yield a
> range hanging off the edge of the input string (out of bounds). The
> five lines include a safeguard against that when assertion checking is
> off.

If you think it is actually likely to happen in practice, then an Assert
is 100% inappropriate. Throw an actual error instead. Code that has
provisions for continuing after an Assert failure is wrong by definition.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Fetter 2010-08-13 17:05:07 Re: patch: General purpose utility functions used by the JSON data type
Previous Message Robert Haas 2010-08-13 16:59:48 Re: patch: General purpose utility functions used by the JSON data type