<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Dec 31, 2015 at 11:05 AM, Augie Fackler <span dir="ltr"><<a href="mailto:raf@durin42.com" target="_blank">raf@durin42.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">diff --git a/mercurial/manifest.c b/mercurial/manifest.c<br>
--- a/mercurial/manifest.c<br>
+++ b/mercurial/manifest.c<br>
@@ -500,6 +500,9 @@ static int lazymanifest_setitem(<br>
        }<br>
<br>
        pyhash = PyTuple_GetItem(value, 0);<br>
+       if (!pyhash) {<br>
+               return -1;<br>
+       }<br></blockquote><div><br></div><div>This is unnecessary. The only way it could fail is with a too-small tuple, but you've already checked the size earlier.</div><div><br></div><div>Once again, this could be a PyTuple_GET_ITEM for speed.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
        if (!PyString_Check(pyhash)) {<br>
                PyErr_Format(PyExc_TypeError,<br>
                             "node must be a 20-byte string");<br>
@@ -518,8 +521,14 @@ static int lazymanifest_setitem(<br>
                return -1;<br>
        }<br>
        hash = PyString_AsString(pyhash);<br>
+       if (!hash) {<br>
+               return -1;<br>
+       }<br></blockquote><div><br></div><div>Either the PyString_Check or the PyString_AsString is unnecessary here. See previous comments.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
        pyflags = PyTuple_GetItem(value, 1);<br>
+       if (!pyflags) {<br>
+               return -1;<br>
+       }<br></blockquote><div><br></div><div>Also unnecessary.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
        if (!PyString_Check(pyflags) || PyString_Size(pyflags) > 1) {<br></blockquote><div><br></div><div>You could use PyString_GET_SIZE here.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                PyErr_Format(PyExc_TypeError,<br>
                             "flags must a 0 or 1 byte string");<br>
_______________________________________________<br>
Mercurial-devel mailing list<br>
<a href="mailto:Mercurial-devel@selenic.com">Mercurial-devel@selenic.com</a><br>
<a href="https://selenic.com/mailman/listinfo/mercurial-devel" rel="noreferrer" target="_blank">https://selenic.com/mailman/listinfo/mercurial-devel</a><br>
</blockquote></div><br></div></div>