openbsd-ports/devel/protobuf-c/patches/patch-src_google_protobuf-c_protobuf-c_c
dcoppa 93c093c24e Import devel/protobuf-c, a C implementation of google protocol
buffers.

This is a new dependency of an upcoming update of audio/umurmur.

Tested by Jonathon Sisson, who also takes maintainership
OK ajacoutot@
2011-07-08 08:58:02 +00:00

59 lines
2.3 KiB
Plaintext

$OpenBSD: patch-src_google_protobuf-c_protobuf-c_c,v 1.1.1.1 2011/07/08 08:58:02 dcoppa Exp $
malloc.h is obsolete
Be more permissive in accepting packed data for non-packed repeated
members (upstream svn revision r285)
--- src/google/protobuf-c/protobuf-c.c.orig Thu Mar 10 20:02:48 2011
+++ src/google/protobuf-c/protobuf-c.c Thu Jul 7 17:14:06 2011
@@ -38,11 +38,6 @@
#include <stdio.h> /* for occasional printf()s */
#include <stdlib.h> /* for abort(), malloc() etc */
#include <string.h> /* for strlen(), memcpy(), memmove() */
-#if HAVE_ALLOCA_H
-#include <alloca.h>
-#elif HAVE_MALLOC_H
-#include <malloc.h>
-#endif
#ifndef PRINT_UNPACK_ERRORS
#define PRINT_UNPACK_ERRORS 1
@@ -1983,6 +1978,14 @@ no_unpacking_needed:
}
static protobuf_c_boolean
+is_packable_type (ProtobufCType type)
+{
+ return type != PROTOBUF_C_TYPE_STRING
+ && type != PROTOBUF_C_TYPE_BYTES
+ && type != PROTOBUF_C_TYPE_MESSAGE;
+}
+
+static protobuf_c_boolean
parse_member (ScannedMember *scanned_member,
ProtobufCMessage *message,
ProtobufCAllocator *allocator)
@@ -2007,8 +2010,8 @@ parse_member (ScannedMember *scanned_member,
case PROTOBUF_C_LABEL_OPTIONAL:
return parse_optional_member (scanned_member, member, message, allocator);
case PROTOBUF_C_LABEL_REPEATED:
- if (field->packed
- && scanned_member->wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
+ if (scanned_member->wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED
+ && (field->packed || is_packable_type (field->type)))
return parse_packed_repeated_member (scanned_member, member, message);
else
return parse_repeated_member (scanned_member, member, message, allocator);
@@ -2261,8 +2264,8 @@ protobuf_c_message_unpack (const ProtobufCMess
if (field != NULL && field->label == PROTOBUF_C_LABEL_REPEATED)
{
size_t *n = STRUCT_MEMBER_PTR (size_t, rv, field->quantifier_offset);
- if (field->packed
- && wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED)
+ if (wire_type == PROTOBUF_C_WIRE_TYPE_LENGTH_PREFIXED
+ && (field->packed || is_packable_type (field->type)))
{
size_t count;
if (!count_packed_elements (field->type,